how to sink a custom defined event class ?

56 views
Skip to first unread message

wahaha

unread,
Dec 5, 2011, 5:08:54 AM12/5/11
to Google Web Toolkit
we use the method sinkEvents(Event.ONCLICK) to tell widget that it
should capture the mouse-click event on this widget.
but if the event is a custom defined event called MyEvent,then what is
the property of method sinkEvents(int eventBitsToAdd)?

Thomas Broyer

unread,
Dec 5, 2011, 6:53:39 AM12/5/11
to google-we...@googlegroups.com
sinkEvents is only for DOM events (ones that are dispatched by the browser itself). In "modern" GWT development you shouldn't have to ever call sinkEvents (use addDomHandler).

For custom events, use addHandler.

Karthik Reddy

unread,
Dec 5, 2011, 4:04:18 PM12/5/11
to google-we...@googlegroups.com
" In "modern" GWT development you shouldn't have to ever call sinkEvents (use addDomHandler)."

CellTable and other Cell based widgets use the sinkEvents approach.  Am I missing something? Is that just an anomaly because of the ultra-high-performance expected off of huge-data-rendering  Cell based widgets? 

wahaha

unread,
Dec 5, 2011, 9:24:20 PM12/5/11
to Google Web Toolkit
but if i need define a event called onPage(fired by logical,not DOM
event) for my widget,how should i register this event and bind handler
for it?

Thomas Broyer

unread,
Dec 6, 2011, 5:04:52 AM12/6/11
to google-we...@googlegroups.com
As I said: addHandler(myHandler, PageEvent.TYPE);

Thomas Broyer

unread,
Dec 6, 2011, 5:11:24 AM12/6/11
to google-we...@googlegroups.com
Cell widgets are special, because they have to listen to any event their Cell(s) want to be notified about, and they process (almost) all of these events the same: 1) find the relevant value and Cell, 2) dispatch the event to the CellPreviewEvent.Handlers if any, then 3) pass the event down to the Cell.
(with a few exceptions needing special treatment in addition to the above: keyboard navigation and "hover" styling)
Reply all
Reply to author
Forward
0 new messages