Merge pull request #32 from frosch95/fix_enter_bug

When pressing enter leave the editing mode
This commit is contained in:
2022-10-22 21:27:37 +02:00
committed by GitHub
4 changed files with 5 additions and 10 deletions

View File

@@ -15,7 +15,7 @@ even in a "normal" CSV editor. So I decided to write this simple JavaFX applicat
[Wiki & Documentation](https://github.com/frosch95/SmartCSV.fx/wiki) [Wiki & Documentation](https://github.com/frosch95/SmartCSV.fx/wiki)
binary distribution of the [latest release (1.3.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.3.0/SmartCSV.fx-1.3.0.zip) binary distribution of the [latest release (1.4.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.4.0/SmartCSV.fx-1.4.0.zip)
## Talks ## Talks
[Introduction](http://javafx.ninja/talks/introduction/) [Introduction](http://javafx.ninja/talks/introduction/)

View File

@@ -48,5 +48,5 @@ test {
} }
group 'ninja.javafx' group 'ninja.javafx'
version '1.3.0' version '1.4.0'
mainClassName = 'ninja.javafx.smartcsv.Main' mainClassName = 'ninja.javafx.smartcsv.Main'

View File

@@ -65,8 +65,8 @@ public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
@Override @Override
public void cancelEdit() { public void cancelEdit() {
super.cancelEdit();
setText(getItem().getValue()); setText(getItem().getValue());
super.cancelEdit();
setContentDisplay(ContentDisplay.TEXT_ONLY); setContentDisplay(ContentDisplay.TEXT_ONLY);
} }
@@ -113,16 +113,11 @@ public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2); textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
textField.setOnKeyPressed(t -> { textField.setOnKeyPressed(t -> {
if (t.getCode() == KeyCode.ENTER) { if (t.getCode() == KeyCode.ENTER) {
commitEdit(textField.getValue()); runLater(() -> commitEdit(textField.getValue()));
} else if (t.getCode() == KeyCode.ESCAPE) { } else if (t.getCode() == KeyCode.ESCAPE) {
cancelEdit(); cancelEdit();
} }
}); });
textField.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue && textField != null) {
commitEdit(textField.getValue());
}
});
} }
private static class ValueTextField extends TextField { private static class ValueTextField extends TextField {

View File

@@ -1,5 +1,5 @@
application.name = SmartCSV.fx application.name = SmartCSV.fx
application.version = 1.3.0 application.version = 1.4.0
# fxml views # fxml views
fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml