Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javafx + FXML + Accelerators --- Platform independence?

Every tutorial about accelerators teaches how to use them FROM CODE, not from fxml files. There you'll learn how tu use the predefined KeyCombinations in order to achieve platform independence.

Now I wonder, if I write this in fxml:

<MenuItem mnemonicParsing="false" text="%menu.save" >
    <accelerator>
       <KeyCodeCombination alt="UP" code="Z" control="UP"meta="DOWN" shift="UP" shortcut="UP" />
    </accelerator>
</MenuItem>

which should APPLE+S on mac, and should be CTRL+S on windows,

this should also work right? (PS: I don't own a windows OS/PC)

like image 991
Jack Shade Avatar asked Mar 19 '15 17:03

Jack Shade


1 Answers

Now it's as simple as:

<MenuItem mnemonicParsing="false" text="%menu.save" accelerator="Shortcut+S"/>

where Shortcut means Ctrl on Windows or Linux and Meta on Mac.
Here's some more information about KeyCombination.

like image 80
kcpr Avatar answered Oct 31 '22 13:10

kcpr