Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8229914

Regression: eventFilter on TextField in editable ComboBox doesn't receive ENTER

XMLWordPrintable

      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());

      }
       

            Unassigned Unassigned
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: