gpt4 book ai didi

java - Vaadin 如何使用 AbstractField.FocusShortcut 中的速记符号将 &Address 转换为 Alt+A?

转载 作者:行者123 更新时间:2023-12-01 11:54:33 27 4
gpt4 key购买 nike

阅读瓦丁之书的这一页:

https://vaadin.com/book/vaadin7/-/page/advanced.shortcuts.html

You can also specify the shortcut by a shorthand notation, where the shortcut key is indicated with an ampersand (&).

// A field with Alt+A bound to it, using shorthand notation
TextField address = new TextField("Address (Alt+A)");
address.addShortcutListener(
new AbstractField.FocusShortcut(address, "&Address"));

This is especially useful for internationalization, so that you can determine the shortcut key from the localized string.

如果我将此 address 文本字段对象添加到我的布局中,然后按 Alt+A,该字段将获得焦点。

但是 Vaadin 如何知道“&Address”是 ALT+A???它是否在内部解析字符串或将其与某些内容进行比较?

键盘快捷键的“&Address”简写符号是什么?还有其他简写符号吗?

最佳答案

来自ShortcutAction javadocs :

Insert one or more modifier characters before the character to use as keycode. E.g "&Save" will make a shortcut responding to ALT-S, "E^xit" will respond to CTRL-X. Multiple modifiers can be used, e.g "&^Delete" will respond to CTRL-ALT-D (the order of the modifier characters is not important).

The modifier characters will be removed from the caption. The modifier character is be escaped by itself: two consecutive characters are turned into the original character w/o the special meaning. E.g "Save&&&close" will respond to ALT-C, and the caption will say "Save&close".

共有三个修饰符:^ (ctrl)、& (alt) 和 _ (shift)。在内部,Vaadin 使用正则表达式来解析速记标题、匹配修饰符并构建键盘快捷键。可以看代码here .

关于java - Vaadin 如何使用 AbstractField.FocusShortcut 中的速记符号将 &Address 转换为 Alt+A?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28541314/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com