On 23 juin, 10:51, Paul Schwarz <paulsschw...@gmail.com> wrote: > Summary: in a CellList I want to sink the ONCLICK and ONCONTEXTMENU > events to be handled by my Cell's onBrowserEvent method, but I don't > want any mouse over/out/move events, but cannot seem to unsink them. > > In 2.1 M1 we have CellList. If you look at the constructor of CellList > you'll see on line 139 > sinkEvents(Event.ONCLICK | Event.ONCHANGE | Event.MOUSEEVENTS); > > So the CellList is presuming that these are the events that we're > interested in. Now I have created my own concrete implementation of an > AbstractCell. > Other implementations are TextCell, ButtonCell, CheckboxCell, etc. So > I have followed those as examples, but have created my own Cell > implementation. > > One of the methods that can be implemented is: > public abstract Object onBrowserEvent(Element parent, C value, Object > viewData, NativeEvent event, ValueUpdater<C> valueUpdater); > > ... and in that method I am interested in a Click event and a Context > menu event. I notice that my CPU usage peaks at 50ish% when I move my > mouse around. Sure enough GWT is picking up all the mouse over, mouse > out, mouse move events as well. AND I'm not getting my Context menu > event (because I haven't explicitly sunk it yet). > > So in my UI class that keeps an instance of this CellList, in the > constructor I have: > myCellList.sinkEvents(Event.ONCONTEXTMENU); > myCellList.unsinkEvents(Event.MOUSEEVENTS); > > ... so now I am getting my Context menu event, but I am still getting > a flood of mouse events as I wiggle my mouse over the Cells in the > CellList. I have tried explicitly unsinking Event.ONMOUSEOVER et al. > but that has no effect either. > > Either this is a bug, or more likely I am unsinking the event on the > wrong element or unsinking in the wrong order, or I am missing > something altogether. > > Any ideas?
Widget#sinkEvents defers the call to DOM.sinkEvents until the widget is attached, but unsinkEvents doesn't, and don't update the "eventsToSink" private variable (this could be seen as a bug in Widget, which should override unsinkEvents too). The workaround seems to be (not tested) to call unsinkEvents from an onLoad override. -- 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-tool...@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.