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

ComboBox setOnKeyPressed() not working for Enter Key

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 7u15
    • Fix Version/s: 8
    • Component/s: javafx
    • Environment:

      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

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

              Dates

              • Due:
                Created:
                Updated:
                Resolved:
                Imported: