-
1 Oct 2009 7:48 AM #1
Strange behavior attaching Listener to a WidgetComponent
Strange behavior attaching Listener to a WidgetComponent
This is a continuation of previous post about turning an icon into a WidgetComponent.
Here's the basic code setup:
This behaves as expected.Code:WidgetComponent w = new WidgetComponent(myIcon); w.setToolTip("test"); w.addListener(Events.OnMouseOver, new Listener<ComponentEvent>() { @Override public void handleEvent(ComponentEvent e) { EventType type = e.getType(); if (type == Events.OnMouseOver) { //do stuff } } });
The strange part is if I remove the w.setToolTip("test") line the other Listener stuff doesn't happen. For some reason the setToolTip() method correctly attaches a listener but just adding a Listener directly doesn't work.
Is this a bug, or am I missing something.Software Developer
Helm Point Solutions, Inc.
-
1 Oct 2009 7:50 AM #2
Its a bug yes, but in your code. When listening to browserevents you will need so sink the event you want to listen to.
setToolTip is doing that because it needs the events.
Code:w.sinkEvents(EVENT.ONMOUSEOVER);
-
1 Oct 2009 7:55 AM #3
That was the issue.
I so enjoy making rookie mistakes.
Thanks again sven.Software Developer
Helm Point Solutions, Inc.


Reply With Quote