Share the post "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:
|
1 |
combobox.addEventFilter(KeyEvent.KEY_RELEASED, this); |
You should now be able to capture the escape, enter and space key events.
when i search something in the combo box when space bar is pressed the first value gets populated. how to give space in the search.kindly help me out
hi. this is an old post. i have forgotten how to use this.