什么是“助记符分析”? Java FX中的属性 [英] What is the "mnemonicParsing" attribute in Java FX

查看:747
本文介绍了什么是“助记符分析”? Java FX中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用SceneBuilder,我发现它应用 mnemonicParsing 的属性并将其等同于 false 对于我制作的每个节点

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.

究竟是什么?它在 Layout.xml 中有什么区别?

What exactly is it? What difference does it make in Layout.xml?

推荐答案

这是指到 标签.mnemonicParsing 属性。它注册一个键盘快捷键来激活元素(使用文本 + Alt <中 _ 后面的字母/ kbd>(Windows,不知道它是否与其他操作系统上的密钥相同))。例如,

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.

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!");
    }
});

还会打印 Hello World!,如果用户按 Alt + S。

Will also print Hello World!, if the user presses Alt + S.

如果 mnemnonicParsing ,则不会发生这种情况是 false 。在这种情况下, _ 也将打印正常,而不是在下面的字母下划线。

This doesn't happen, if mnemnonicParsing is false. In this case the _ will also be printed "normally" instead of underlineing the following letter.

这篇关于什么是“助记符分析”? Java FX中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆