YourWidget.addDomHandler(new KeyUpHandler(){
                        public void onKeyUp(KeyUpEvent event) {
                                // TODO Auto-generated method stub

                        }

                }, KeyUpEvent.getType());


Just like real DOM, you've got to manually add KeyUp, KeyPress and
KeyDown.  This saves on memory leaks, and is more efficient than using
onBrowserEvent()...  Which you can also use.

YourWidget = new FlowPanel(){
                        @Override
                        public void onBrowserEvent(Event event) {
                        switch(event.getTypeInt()){
                        case Event.ONKEYUP:

                        }
                        }
                };

Also, you can manually add an old event listener, but you've got to
set and clear events yourself {that's what HandlerRegistration is
for}:

DOM.setEventListener(YourWidget.getElement(), new EventListener(){
                        public void onBrowserEvent(Event event) {
                                // TODO Auto-generated method stub

                        }
                });
DOM.sinkEvents(YourWidget.getElement(), Event.ONKEYUP);



...If you want to grab key events, only certain DOM elements are
normally capable of receiving key events, so you might want to do:

Event.addNativePreviewHandler(new NativePreviewHandler(){
                        public void onPreviewNativeEvent(NativePreviewEvent 
event) {
                                if (event.getTypeInt()==Event.ONKEYPRESS){

                                }
                        }
                });

JUST MAKE SURE YOU CLEAR THE NATIVE EVENT PREVIEW WHEN YOUR WIDGETS
DETACH, OR STUFF LIKE POPUP PANEL MIGHT DIE ON YOU!
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to