Skip to content

Commit 72a75c5

Browse files
authored
Merge pull request #64 from doubleSlashde/feature/time_validation_on_focus_lost
changed Validation to trigger on focus change
2 parents 90f92da + 84a2db0 commit 72a75c5

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
@@ -103,16 +103,15 @@ private void initialize() {
103103
}
104104

105105
private void setUpTimeSpinner(final Spinner<LocalTime> spinner) {
106-
spinner.getEditor().textProperty().addListener((observable, oldValue, newValue) -> {
106+
spinner.focusedProperty().addListener((e) -> {
107107
final LocalTimeStringConverter stringConverter = new LocalTimeStringConverter(FormatStyle.MEDIUM);
108-
final StringProperty text = (StringProperty) observable;
108+
final StringProperty text = spinner.getEditor().textProperty();
109109
try {
110-
stringConverter.fromString(newValue);
111-
text.setValue(newValue);
110+
stringConverter.fromString(text.get());
112111
// needed to log in value from editor to spinner
113112
spinner.increment(0); // TODO find better Solution
114-
} catch (final DateTimeParseException e) {
115-
text.setValue(oldValue);
113+
} catch (final DateTimeParseException ex) {
114+
text.setValue(spinner.getValue().toString());
116115
}
117116
});
118117

0 commit comments

Comments
 (0)