I have met the same problem.

I have a panel that extends gwtext's panel class.(Gwttxt's panel class
has extended gwt's widget class)

My code:
this.addDomHandler(new KeyPressHandler(){

                        public void onKeyPress(KeyPressEvent event) {
                                System.out.println("dddddddddd");

                        }

                },KeyPressEvent.getType());

                addDomHandler(new KeyUpHandler(){
            public void onKeyUp(KeyUpEvent event) {
                    // TODO Auto-generated method stub
                        System.out.println("dfasdfasdfasdf");
            }

    }, KeyUpEvent.getType());

But nothing happened.

please help me.

On 5月13日, 下午11时51分, bond <daniele.re...@gmail.com> wrote:
> Thanks very much  Alyxandor
>
> Regards
>
> Daniele
>
> On 13 Mag, 15:20, Alyxandor <a.revolution.ultra.b...@gmail.com> wrote:
>
> > 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