3 Replies Latest reply on Jan 3, 2012 11:21 PM by Psomashekar-Oracle

    Alt functionality on menus

      I'm implementing a main menu and wondering if the functionality I'm getting is normal or I'm missing something. Our QA team brought this up.

      On a typical Windows application when I click Alt-F (assuming I have a _File menu), it shows the complete File menu (i.e. shows all subitems below the word File).

      On my JavaFX application, if I click Alt-F, it highlights the File menu, but doesn't show child items unless I click the Down button

      Is there a way to ensure the complete File menu opens when clicking Alt-F?
        • 1. Re: Alt functionality on menus
          The menu class has a method called "setMnemonicParsing" (which is inherited from the MenuItem class). See the java docs on how to use it.

          See: http://docs.oracle.com/javafx/2.0/api/javafx/scene/control/MenuItem.html#setMnemonicParsing(boolean)
          • 2. Re: Alt functionality on menus
            This isn't a problem with Mnemonic parsing, this is a problem with how the menu responds to the parsing.

            I've put an example below. In this example I have one menu (_Items) with three menu items (Item A, Item B, Item _C). When I click Alt+I, I would expect it to pop open the Items menu and show the three menu items.

            Unfortunately, it just highlights the Items menu header, and I don't see the menu items unless I press the Down key. This is not typical menu behavior.

            Am I missing something or is this a bug with JavaFX menus?
            public class JavaFXApplication1 extends Application {
                public static void main(String[] args) {
                @Override public void start(Stage stage) {
                    MenuItem itemA = new MenuItem("Item _A");
                    MenuItem itemB = new MenuItem("Item _B");
                    MenuItem itemC = new MenuItem("Item _C");
                    Menu items = new Menu("_Items");
                    items.getItems().addAll(itemA, itemB, itemC);
                    MenuBar bar = new MenuBar();
                    VBox vp = new VBox();
                    stage.setScene(new Scene(vp, 300, 300));
            • 3. Re: Alt functionality on menus
              Indeed you are right - this is a bug. When you click Alt + I, the Items menu should pop open and show the three menu items.

              However the bug has already been fixed. You should see that this is fixed in our next week's
              promotion - i.e. JavaFX 2.1 build b08 (http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html).