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

ComboBox setOnKeyPressed() not working for Enter Key

    XMLWordPrintable

Details

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

    Description

      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



      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported: