Similarly you should probably also check the type. and you could
emulate the normal handler style of the rest of the GWT architecture.
Event.addNativePreviewHandler(new NativePreviewHandler()
{
@Override
public void onPreviewNativeEvent(NativePreviewEvent event)
{
NativeEvent ne = event.getNativeEvent();
if
(KeyDownEvent.getType().getName().equals(ne.getType()))
System.out.println("Yipeee!");
}
});
On Sep 9, 5:11 pm, Carlos Aguayo <[email protected]> wrote:
> 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, "[email protected]" <[email protected]>
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.