Java FX 中的“mnemonicParsing”属性是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36847934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the "mnemonicParsing" attribute in Java FX
提问by Tilak Maddy
I have been working with SceneBuilder and I observe that it applies the attribute of mnemonicParsing
and equates it to false
for every Node
that I make.
我一直在使用 SceneBuilder,我观察到它应用了我制作的每个属性mnemonicParsing
并将其等同于它。false
Node
What exactly is it? What difference does it make in Layout.xml
?
究竟是什么?它有什么区别Layout.xml
?
回答by fabian
This refers to the Labeled.mnemonicParsing
property. It registers a keyboard shortcut to activate the element (using the letter following _
in the text
+ Alt(Windows, don't know if it's the same key on other OS too)). E.g.
这是指Labeled.mnemonicParsing
财产。它注册了键盘快捷键来激活元素(以下使用的信_
在text
+ Alt(Windows中,不知道这是否对其他操作系统相同的密钥太))。例如
Button btn = new Button();
btn.setText("_Say 'Hello World'");
btn.setMnemonicParsing(true);
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
}
});
Will also print Hello World!
, if the user presses Alt+ S.
Hello World!
如果用户按下Alt+ S ,也会打印。
This doesn't happen, if mnemnonicParsing
is false
. In this case the _
will also be printed "normally"instead of underlineing the following letter.
这不会发生,如果mnemnonicParsing
是false
。在这种情况下,_
也将“正常”打印,而不是在下面的字母下划线。