JDK-8165937 : Menu Mnemonics Don't Work on Linux
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: linux
  • CPU: x86_64
  • Submitted: 2016-09-11
  • Updated: 2016-12-12
  • Resolved: 2016-12-12
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.


Comments
Won't fix for JDK 8 unless there's a concern raised.
12-12-2016

Tested this issue against 8,8u102,8u112ea,9ea on Linux and could reproduce the issue on entire JDK 8 family, but could not on 9ea+b135. Steps to reproduce: ************************* - Run the attached test program(MnemonicTestApp.java) with JDK. - Holding the Alt key, press the E key. The Edit Menu will be selected. - Continuing to hold the Alt key, press the P key. The selecting will go back to the File Menu rather than the Paste MenuItem. Result: ********* OS : Linux - Ubuntu 14.04 LTS 64 bit, Windows 7 64 bit JDK + LinuX (Ubuntu14.04) ++++++++++++++++++++++++++ 8 b132 : Fail 8u102 b14 : Fail 8u112ea b04 : Fail 9ea+135 : Pass [It works intermittently] JDK + Windows 7 +++++++++++++++ 8 b132 : Pass 8u102 b14 : Pass 8u112ea b04 : Pass 9ea+133 : Pass
13-09-2016