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 <[email protected]> wrote:
> Thanks very much Alyxandor
>
> Regards
>
> Daniele
>
> On 13 Mag, 15:20, Alyxandor <[email protected]> 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 [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
-~----------~----~----~----~------~----~------~--~---