Java FX 2 Editable ComboBox Does Not Detect ESC, ENTER, SPACE Key

Well, I bet you coded it the obvious way by using the setOnKeyPresse9) or setOnKeyReleased() method of the ComboBox class. For explanations that I still do not understand and do not care as long as it worked, user James D from the Oracle forum stated that the space, enter and escape key do not register because the button itself of the ComboBox captures that event (and propagates it as an action event), thus consuming it before your event handler.

The solution to this is not to use addEventHandler() but instead use addEventFilter().

This is how to call it:

You should now be able to capture the escape, enter and space key events.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *