GWT中的助记符 [英] Mnemonics in GWT

查看:134
本文介绍了GWT中的助记符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建 Java Swing助记符与GWT。但我不知道如何弄清楚。我用Google搜索了一下,但我并没有喜欢它的任何示例代码。我想在我的按钮上绑定一些键盘快捷键。我怎样才能实现它?任何建议将非常感谢!

I would like to create as Java Swing Mnemonics with GWT . But I don't know how to figure it out. I have googled for it but I didn't fond any sample codes for it . I want to bind some keyboard shortcut keys on my buttons. How can I achieve it ? Any suggestions would be really appreciated !

推荐答案

一般来说,您可以使用NativePreviewHandler处理全局键盘快捷键。一个例子可以在这里看到:

In general you can handle global keyboard shortcusts using a NativePreviewHandler. An example of this can you see here:

NativePreviewHandler nativePreviewHandler = new NativePreviewHandler() {

    @Override
    public void onPreviewNativeEvent(NativePreviewEvent event) {
        if (event.getTypeInt() != Event.ONKEYDOWN) {
            return;
        }
        final NativeEvent nativeEvent = event.getNativeEvent();
        final boolean altKey = nativeEvent.getAltKey();
        final boolean ctrlKey = nativeEvent.getCtrlKey();
        if(altKey && ctrlKey && nativeEvent.getKeyCode() == 'A') {
            // Do Something
        }
    }
};
Event.addNativePreviewHandler(nativePreviewHandler);

但是据我所知,GWT中没有通用的方式来处理某种Action绑定到按钮/菜单以及键盘快捷键。你必须自己实现这样的抽象。

But as far as I klnow, there's no generic way build into GWT to handle some kind of Action that is bound to a button/Menu as well as a keyboard shortcut. You will have to implement such an abstraction by yourselves.

这篇关于GWT中的助记符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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