每个关于加速器的教程都讲授如何使用FROM CODE,而不是fxml文件。在那里,您将学习如何使用预定义的KeyCombinations来实现平台独立性。
现在我想知道,如果我用fxml写这个:
<MenuItem mnemonicParsing="false" text="%menu.save" >
<accelerator>
<KeyCodeCombination alt="UP" code="Z" control="UP"meta="DOWN" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
在mac上应该是APPLE + S ,在Windows上应该是 CTRL + S
这应该也适用吗? (PS:我不拥有Windows OS / PC)
答案 0 :(得分:11)
现在它很简单:
<MenuItem mnemonicParsing="false" text="%menu.save" accelerator="Shortcut+S"/>
其中Shortcut
表示Windows或Linux上的 Ctrl 和Mac上的 Meta 。
Here's some more information about KeyCombination