每个关于加速器的教程都教您如何通过CODE(而不是fxml文件)使用它们。在那里,您将学习tu如何使用预定义的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)
现在就这么简单:
<MenuItem mnemonicParsing="false" text="%menu.save" accelerator="Shortcut+S"/>
其中Shortcut
在Windows或Linux上表示Ctrl,在Mac上表示Meta。Here's some more information about KeyCombination
。
首先,谢谢。现在我有一些问题。当我尝试在FXML文件上使用加速器时
KeyCombination
我收到一个错误“ KeyCodeCombination类不存在”,并且我不知道原因。
谢谢。