tornadofx-controls icon indicating copy to clipboard operation
tornadofx-controls copied to clipboard

DateTimePicker not updating user changes (without Enter)

Open ENeMy235 opened this issue 3 years ago • 0 comments

Hi, I just tried to use your code for DateTimePicker and I found a bug. When you user modifies value in textfield, DateValue doesn't get updated. This is not happening when user confirms his changes with Enter. Your code has listener on focusedProperty so I though it should be working even without Enter press.

After some time of debugging I found that simulatedEnterPressed() is calling getEditor.commitValue(). I tried to change that to fireEvent to press Enter but with no success. So I went deeper into commitValue() -> that is depending on Textformatter which is NULL. When formatter is null, it cant update the value.

I fixed everything with new line of code in DateTimePicker constructor: getEditor().setTextFormatter(new TextFormatter<>(getConverter()));

After this line everything works. I hope it helps someone. Maybe problem is just with JavaFX version (I'm using openJFX 15.0.1 )

ENeMy235 avatar Mar 02 '21 13:03 ENeMy235