开发者

window.onkeyup in GWT

开发者 https://www.devze.com 2022-12-15 00:52 出处:网络
How do I convert the javascript code \"window.onkeyup\" (or o开发者_如何学编程nkeyup in body tag) to GWT?

How do I convert the javascript code "window.onkeyup" (or o开发者_如何学编程nkeyup in body tag) to GWT?

Regards


For a page wide listener, you want to take a look at Event.addNativePreviewHandler. Attaching a keyup listener there should give you the effect you want. Modifing the snippet here should get you started:

Event.addNativePreviewHandler(new NativePreviewHandler() {
  public void onPreviewNativeEvent(final NativePreviewEvent event) {
    final int eventType = event.getTypeInt();
    switch (eventType) {
      case Event.ONKEYUP:
        //magic here
        break;
      default:
        // not interested in other events
    }
  }
});


I think you could do that with KeyboardListener.

There is a good discussion thread about it (and some issues): http://groups.google.com/group/google-web-toolkit/browse_thread/thread/6072c87aa27a2d6e/524334b959683f77

0

精彩评论

暂无评论...
验证码 换一张
取 消