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

ComboBox setOnKeyPressed() not working for Enter Key

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 8
    • 7u15
    • javafx
    • Win XP 32/64, Windows-7 32/64 and Mac OSX

      I am using the following code

      libraryCombo.setOnKeyPressed(new EventHandler<KeyEvent>(){
                  @Override
                  public void handle(KeyEvent t) {
                      if (t.getCode() == KeyCode.ENTER) {
                          btn_OkAction.requestFocus();
                          makeOKAction(null);
                      }
                  }
              });

      Where libraryCombo is the object of ComboBox

      But this code is not working for Enter Key but for Other Keys it os working properly.

      I also tried this but has the same behavior

      libraryCombo.getEditor().addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>(){
                  @Override
                  public void handle(KeyEvent t) {
                      if (t.getCode() == KeyCode.ENTER) {
                          btn_OkAction.requestFocus();
                          makeOKAction(null);
                      }
                  }
              });

      Please have a look.

      Thanks



            jgiles Jonathan Giles
            rahuljfx Rahul (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: