Skip to content

Commit 4717917

Browse files
author
Jan Schraff
committed
changed Validation to trigger on focus change
1 parent b91a240 commit 4717917

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/main/java/de/doubleslash/keeptime/view/ManageWorkController.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,15 @@ private void initialize() {
9494
}
9595

9696
private void setUpTimeSpinner(final Spinner<LocalTime> spinner) {
97-
spinner.getEditor().textProperty().addListener((observable, oldValue, newValue) -> {
97+
spinner.focusedProperty().addListener((e) -> {
9898
final LocalTimeStringConverter stringConverter = new LocalTimeStringConverter(FormatStyle.MEDIUM);
99-
final StringProperty text = (StringProperty) observable;
99+
final StringProperty text = spinner.getEditor().textProperty();
100100
try {
101-
stringConverter.fromString(newValue);
102-
text.setValue(newValue);
101+
stringConverter.fromString(text.get());
103102
// needed to log in value from editor to spinner
104103
spinner.increment(0); // TODO find better Solution
105-
} catch (final DateTimeParseException e) {
106-
text.setValue(oldValue);
104+
} catch (final DateTimeParseException ex) {
105+
text.setValue(spinner.getValue().toString());
107106
}
108107
});
109108

0 commit comments

Comments
 (0)