JavaFX - Show accelerator modifiers in Menu

418 views Asked by At

I have a simple JavaFX application and a MenuBar. I have set some accelerators in the fxml and they work fine, but only the main keys are shown, not the modifiers.

For example:
(see screenshot below)
Save and Save as... both have S as main key, but Save as... has an extra modifier SHIFT_ANY. In the application, both MenuItems only have the letter S next to them.

Again, the accelerators work fine, they are just not shown correctly.

Is there a way to force JavaFX to show the modifiers as well?

Thanks

application screenshot

Here's the fxml of the Menu in question.

<Menu mnemonicParsing="false" text="File">
            <MenuItem mnemonicParsing="false" onAction="#newFile" text="New">
                <accelerator>
                    <KeyCodeCombination alt="UP" code="N" control="ANY" meta="UP" shift="UP" shortcut="UP"/>
                </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#open" text="Open...">
                <accelerator>
                    <KeyCodeCombination alt="UP" code="O" control="ANY" meta="UP" shift="UP" shortcut="UP"/>
                </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#save" text="Save">
                <accelerator>
                    <KeyCodeCombination alt="UP" code="S" control="ANY" meta="UP" shift="UP" shortcut="UP"/>
                </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#saveAs" text="Save as...">
                <accelerator>
                    <KeyCodeCombination alt="UP" code="S" control="ANY" meta="UP" shift="ANY" shortcut="UP"/>
                </accelerator>
            </MenuItem>
            <SeparatorMenuItem mnemonicParsing="false"/>
            <MenuItem mnemonicParsing="false" onAction="#quit" text="Quit">
                <accelerator>
                    <KeyCodeCombination alt="UP" code="Q" control="ANY" meta="UP" shift="UP" shortcut="UP"/>
                </accelerator>
            </MenuItem>
        </Menu>
1

There are 1 answers

0
AudioBubble On BEST ANSWER

I've found the problem:
In the FXML I had set CONTROL="ANY" instead of CONTROL="DOWN".
I hadn't noticed the mistake :) Everything works fine now.

Sorry to have bothered you.