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

Mnemonics don't work without Alt when MenuBar is activated with Alt or F10

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8u40
    • javafx
    • None

      Run the snippet below and put the focus into the TextField and activate the menu using ALT and then type "e" and notice:
      - that the character is also showing up in the text-field
      - the Edit menu is not opened

      I'm marking this as a major bug because it makes mnemonics completely unusable in many applications

      package application;

      import javafx.application.Application;
      import javafx.stage.Stage;
      import javafx.scene.Scene;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.BorderPane;


      public class Main extends Application {
      @Override
      public void start(Stage primaryStage) {
      try {
      BorderPane root = new BorderPane();
      MenuBar b = new MenuBar();

      {
      Menu m = new Menu("_File");

      MenuItem i = new MenuItem("Tes_t");
      i.setOnAction( e -> System.err.println("Called!!!!"));
      m.getItems().add(i);

      b.getMenus().add(m);
      }

      {
      Menu m = new Menu("_Edit");

      MenuItem i = new MenuItem("Te_st");
      m.getItems().add(i);

      b.getMenus().add(m);
      }

      root.setTop(b);
      root.setCenter(new TextField());

      Scene scene = new Scene(root,400,400);
      scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.show();
      } catch(Exception e) {
      e.printStackTrace();
      }
      }

      public static void main(String[] args) {
      launch(args);
      }
      }

            jgiles Jonathan Giles
            tschindl Tom Schindl
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: