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

2010-09-09 Thread Carlos Aguayo
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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



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

2010-09-09 Thread lineman78
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 carlos.agu...@gmail.com 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, 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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Adding Event Handlers on the body element...

2010-08-09 Thread seth.ho...@gmail.com
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 :

  body onkeypress=return keyPress(event); onkeydown=return
keyDown(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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.