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

ComboBoxListViewSkin has ineffective event filter

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx

      In ComboBoxListViewSkin there is an event filter which begins like this:

              comboBox.addEventFilter(InputEvent.ANY, new EventHandler<InputEvent>() {
                  @Override public void handle(InputEvent t) {
                      if (textField == null) return;
                      
                      // When the user hits the enter or F4 keys, we respond before
                      // ever giving the event to the TextField.
                      if (t instanceof KeyEvent) {

      This registers filter to all existing input events and than does instanceof to only filter key events. This is ineffective and ugly. The filter should be only registered to events it wants to process. You should replace InputEvent.ANY by KeyEvent.ANY, handle KeyEvents only and get rid of the instanceof check and cast.

              comboBox.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() {
                  @Override public void handle(KeyEvent ke) {

            jgiles Jonathan Giles
            psafrata Pavel Ĺ afrata
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: