JDK-8229914 : Regression: eventFilter on TextField in editable ComboBox doesn't receive ENTER
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: jfx11,jfx12,jfx13
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2019-08-20
  • Updated: 2024-06-11
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.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
To reproduce, compile and run the example below
- press enter in the combo's textField
- expected: log message printed
- actual: nothing printed

This is a regression of JDK-8145515, probably (don't have an intermediate version handy to verify) introduced by fixing JDK-8149622.

Both fixes reside in ComboBoxPopupControl.handleKeyEvent. The fixing idea (afaiu) of the former was to fire a not consumed enter onto the textField (and prevent back-fireing by a custom flag on the textField properties). After fixing the latter, an uncomsumed enter is only fired for eventType keyReleased. 

The example:

public class TextFieldInComboBug extends Application {

    private Parent createContent() {
        ComboBox<String> comboBox = new ComboBox<>();
        comboBox.setEditable(true);
        comboBox.getItems().addAll("something to choose", "another thingy to have");
        // regression of https://bugs.openjdk.java.net/browse/JDK-8145515
        // ENTER not received
        comboBox.getEditor().addEventFilter(KeyEvent.KEY_PRESSED, e -> {
            LOG.info("got key in editor filter: " + e);
        });

        VBox content = new VBox(10, comboBox);
        return content;
    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setScene(new Scene(createContent()));
        //stage.setTitle(FXUtils.version());
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

    @SuppressWarnings("unused")
    private static final Logger LOG = Logger
            .getLogger(TextFieldInComboBug.class.getName());

}