stopping event propagation?

134 views
Skip to first unread message

Ossie

unread,
May 24, 2006, 3:56:04 PM5/24/06
to Google Web Toolkit
Hi All,

Is there a way in GWT to stop event propagation? In Firefox there's a
javascript stopPropagation() function, is there an analogue to that in
the GWT world?

Our problem: we've got a CheckBox within a FocusPanel, both of which
source click events. When somebody clicks on the checkbox, our listener
receives two onClick calls - one for the checkbox and one for the
FocusPanel. But we only want to trap the event from the CheckBox in
this situation; we only want to get the FocusPanel click event when the
user clicks outside of the checkbox.

Since the CheckBox event always arrives first (at least in our limited
testing), it would be nice to catch that event and somehow prevent
further processing. Is there a way to do that in GWT? Any tips, ideas
or other info would be much appreciated..

Cheers,
Ossie

Henry

unread,
May 25, 2006, 9:47:09 AM5/25/06
to Google Web Toolkit
Something like this may be exactly what you need. We're looking into
extending the event framework to allow for easier/better cancellation
of events, so this may change in the future, but that comes with Beta
territory...

NoMouseEventPropCheckBox extends CheckBox {

public void onBrowserEvent(Event event) {
// Cancel bubbling for all mouse events. This will hide them from all
// widgets above this one in the containment hierarchy.
if ((DOM.eventGetType(event) & Event.MOUSEEVENTS) != 0)
DOM.eventCancelBubble(event, true);

// Don't forget to allow the normal event handling to occur.
super.onBrowserEvent(event);
}
}

Thanks,

Henry

Reply all
Reply to author
Forward
0 new messages