JDK-8145515 : addEventFilter for combobox editor does not react on key action enter
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u66,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-12-14
  • Updated: 2019-10-01
  • Resolved: 2016-06-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
3.11-2-amd64 #1 SMP Debian 3.11.8-1 (2013-11-13) x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
Im using an ComboBox which  has an added KeyPressEventFilter . When the user press enter while the focus is on the combobox, the   if (e.getCode() == KeyCode.ENTER)  condition should be true and some logic should be executed. Which was working on jdk 1.8_45 but in the newer releases the listener does not react on the key enter(other keys are working). 

REGRESSION.  Last worked in version 8u45

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Declare and initialize a ComboBox

- Add  on the editor of the ComboBox an EventFilter for KeyEvent.Key_Pressed(  comboBoxSearchResults.getEditor().addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {)

-Focus the ComboBox and press enter


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The logic which is implemented in the EventFilter should be executed
ACTUAL -
The logic will be not executed because the EventFilter does not catch the enter key press

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
ComboBox<SearchResult> comboBoxSearchResults;
comboBoxSearchResults.setItems(searchResults);
comboBoxSearchResults.setConverter(new SearchResultStringConverter(searchResults));
comboBoxSearchResults.getEditor().addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
            if (e.getCode() == KeyCode.ENTER) {
          
                    //some logic
            }

        });
---------- END SOURCE ----------


Comments
hmm ... don't quite understand whether (and if so, how?) or not this is fixed (in fx11): - the requirement was to let an eventFilter on the combo's editor get hold of enter - the bug was that the filter never saw the enter (because it was blocked, to protect against event storm) - the fix (?) was to allow the filter to receive the enter (while at the same time prevent the storm) - the current (fx11) state is that the filter doesn't receive the enter unfixed or yet another regression?
19-08-2019

Changeset: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/70740792d5c0
20-06-2016

The basic issue is that the Enter key is special-cased in a few places, and resolving this leads to an event storm that results in a stack overflow. Refer to the 'forwardToParent' methods in TextFieldBehavior, TextInputControlBehavior, and ComboBoxPopupControl. Also, TextFieldBehavior.fire(), which forwards the KeyEvent to the parent node if onAction is null and the actionEvent is not consumed. Whilst this remains a regression, my preference is to not resolve this for JDK 9, as it will require a lot of changes. Alternatively, if this needs to be fixed for JDK 9, I think that needs to be decided soon so that I can get this resolved and integrated with enough runway to ensure no other regressions creep in.
23-03-2016