feat: improve username dialog text handling
This commit is contained in:
parent
3ed38442dc
commit
8d45d4c7e2
2 changed files with 13 additions and 8 deletions
|
@ -77,12 +77,8 @@ public class ChatFooterController implements Initializable {
|
|||
textField.setOnKeyPressed(event -> {
|
||||
if (event.getCode() == KeyCode.ENTER) {
|
||||
event.consume();
|
||||
if (event.isShiftDown()) {
|
||||
textField.appendText(System.getProperty("line.separator"));
|
||||
} else {
|
||||
if(!textField.getText().isEmpty()){
|
||||
onSend();
|
||||
}
|
||||
if(!textField.getText().isEmpty()){
|
||||
onSend();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import javafx.beans.value.ObservableValue;
|
|||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.layout.StackPane;
|
||||
|
||||
import java.net.URL;
|
||||
|
@ -74,6 +75,7 @@ public class EditUsernameDialogController implements Initializable {
|
|||
setLocked(false);
|
||||
setFieldError(State.VALID);
|
||||
setMode(mode);
|
||||
textField.setText("");
|
||||
dialog.show(root);
|
||||
}
|
||||
|
||||
|
@ -85,7 +87,7 @@ public class EditUsernameDialogController implements Initializable {
|
|||
}
|
||||
|
||||
private void setLocked(boolean state) {
|
||||
confirmButton.setDisable(state);
|
||||
confirmButton.setDisable(state || textField.getText().isEmpty());
|
||||
cancelButton.setDisable(state);
|
||||
dialog.setOverlayClose(!state);
|
||||
textField.setDisable(state);
|
||||
|
@ -129,9 +131,16 @@ public class EditUsernameDialogController implements Initializable {
|
|||
validator = new Validator();
|
||||
currentState = State.VALID;
|
||||
setMode(Mode.INITIAL);
|
||||
confirmButton.setDisable(true);
|
||||
textField.textProperty().addListener(this::onUsernameChange);
|
||||
textField.getValidators().add(validator);
|
||||
textField.setOnKeyPressed(event -> {
|
||||
if (event.getCode() == KeyCode.ENTER) {
|
||||
event.consume();
|
||||
if(!textField.getText().isEmpty()){
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onSuccess() {
|
||||
|
|
Loading…
Reference in a new issue