Thursday, September 9, 2010

Re: Adding Event Handlers on the body element...

You can try something like this:

Event.addNativePreviewHandler(new NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
int KEY_F8 = 119;
if ("keyup".equals(event.getNativeEvent().getType()) &&
event.getNativeEvent().getKeyCode() == KEY_F8) {
// do something onkeyup && f8
}
}
});


On Aug 6, 8:45 pm, "seth.ho...@gmail.com" <seth.ho...@gmail.com>
wrote:
> Hello,
>
> I'm using GWT for 2 years now and i did many great things with it.
> However, i'm still looking for how to implements KeyboardHandlers on
> the BodyElement.
> The only way i found is writing something like this in the HTML file :
>
>   <bodyonkeypress="return keyPress(event);" onkeydown="returnkeyDown(event);" onkeyup="return keyUp(event);">
>
> And something like that in the EntryPoint
>
> public void onModuleLoad() {
>         // publish();}
>
> private native final void publish() /*-{
>         $wnd["keyPress"] = function(event) {
>                 @webapp.client.Application::keyPress(Lcom/google/gwt/dom/client/
> NativeEvent;)(event);
>         }
>         $wnd["keyUp"] = function(event) {
>                 @webapp.client.Application::keyUp(Lcom/google/gwt/dom/client/
> NativeEvent;)(event);
>         }
>         $wnd["keyDown"] = function(event) {
>                 @webapp.client.Application::keyDown(Lcom/google/gwt/dom/client/
> NativeEvent;)(event);
>         }
>
> }-*/;
>
> But i'm really not satisfied with that solution.
> Any ideas please ?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment