edvin / tornadofx-controls

CSS Stylable Controls for JavaFX
Apache License 2.0
107 stars 16 forks source link

DateTimePicker not updating user changes (without Enter) #12

Open ENeMy235 opened 3 years ago

ENeMy235 commented 3 years ago

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 )