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

Menu Mnemonics Don't Work on Linux

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      1.8.0_102 and additionally verified on _92 and _66

      ADDITIONAL OS VERSION INFORMATION :
      Ubuntu 16.04

      A DESCRIPTION OF THE PROBLEM :
      I have an app with a Menubar with two Menus. Each Menu has a single MenuItem. All of the Menus and MenuItems have mnemonicParsing set to the default (true) and a mnemonic applied via the underscore ('_') character.

      When I press Alt, I can select the Menu. However, continuing to hold Alt does not allow me to select a MenuItem.

      I've seen this example work intermittently, but the larger program that I can't submit has mnemonics that never work.

      This program works fine on Windows and mnemonics aren't used on the Mac.





      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      In my test program, one of the menus is File > Close. The other is Edit > Paste. To reproduce

      1. Start the app
      2. Holding the Alt key, press the E key. The Edit Menu will be selected.
      3. Continuing to hold the Alt key, press the P key. The selecting will go back to the File Menu rather than the Paste MenuItem.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected to be able to select a MenuItem with the mneomic.
      ACTUAL -
      The MenuItem is not selected. Focus seems to go back to the first Menu.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class MnemonicTestApp extends Application {

          @Override
          public void start(Stage primaryStage) throws Exception {

              MenuBar menubar = new MenuBar();

              Menu fileMenu = new Menu("_File");
              fileMenu.setMnemonicParsing(true);

              MenuItem closeItem = new MenuItem("_Close");
              closeItem.setId( "closeItem");
              closeItem.setMnemonicParsing(true);
              closeItem.setOnAction( this::activate );

              fileMenu.getItems().add( closeItem );

              Menu editMenu = new Menu("_Edit");
              editMenu.setMnemonicParsing(true);

              MenuItem pasteItem = new MenuItem("_Paste");
              pasteItem.setId( "pasteItem" );
              pasteItem.setMnemonicParsing( true );
              pasteItem.setOnAction( this::activate );

              editMenu.getItems().add( pasteItem );

              menubar.getMenus().addAll( fileMenu, editMenu );

              VBox vbox = new VBox();
              vbox.getChildren().addAll( menubar );

              Scene scene = new Scene( vbox, 480, 320 );

              primaryStage.setScene( scene );
              primaryStage.show();
          }

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

          private void activate(Event event) {
              System.out.println("source=" + event.getSource());
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Don't use mnemonics.

        Attachments

          Activity

            People

            • Assignee:
              scfitch Stephen Fitch
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: