Friday, May 27, 2011

Re: Global event handler

Have you taken a look at the static Event.addNativePreviewHandler method?

Example:

Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
switch (event.getTypeInt()) {
case Event.ONKEYDOWN:
int keyCode = event.getNativeEvent().getKeyCode();
// .....
}
}
});



On Fri, May 27, 2011 at 3:35 PM, pjspychala <tomatoactivator@gmail.com> wrote:
I want to catch certain keypress events that get caught no matter what
widget is focused.

I have:

public class MainController {
 public void onModuleLoad()
 {
   RootLayoutPanel.get().add(new MainView());
 }
}

public class MainView extends Composite implements
HasKeyPressHandlers, KeyPressHandler {
 public MainView() {
   this.addKeyPressHandler(this);
   addManyWidgets();
 }
 void onKeyPress(...) { ... }
 HandlerResitration addKeyPressHandler(...) {  ... }
}

But the events get only caught when the focus is in a widget in
mainview and are NOT caught when I just click anywhere (thats not a
focusable widget) in the mainview.

--
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.


--
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