How to catch mouse events on the Tree?

199 views
Skip to first unread message

gwt_user

unread,
Sep 10, 2008, 12:34:18 PM9/10/08
to Google Web Toolkit
I want to catch double click and right click events on the tree items.

Here is the tree:

<code>
Tree tree = new Tree(){
public void onBrowseEvent(Event e) {
GWT.log("Browse event happened", null);
if(DOM.eventGetType(e) == Event.ONDBLCLICK) {
GWT.log("Double clicked.", null);

}
}
};

tree.sinkEvents(Event.ONDBLCLICK);
</code>

When I double click on any tree item, onBrowseEvent method is never
called.

gwt_user

unread,
Sep 10, 2008, 3:49:42 PM9/10/08
to Google Web Toolkit
I forgot to mention that I am using GWT 1.5.2.

gwt_user

unread,
Sep 11, 2008, 11:01:35 AM9/11/08
to Google Web Toolkit
Ok, I figured that out.

1. I misspelled 'onBrowseEvent' - it must be 'onBrowserEvent'.

2. I did not call super.onBrowserEvent() in onBrowserEvent.

The code that works is:

<code>
Tree tree = new Tree(){
public void onBrowserEvent(Event e) { {
sinkEvents(Event.ONDBLCLICK);
}
super.onBrowserEvent(e);
if(DOM.eventGetType(e) == Event.ONDBLCLICK) {
GWT.log("Double clicked.", null);

}
}
};
</code>

Hope this will help to someone new to GWT like me.
Reply all
Reply to author
Forward
0 new messages