简体   繁体   中英

GWT - How to stop propagation from a child's event to its parent

I'm building a GWT application with a Tree. Every tree items represent an object which has a boolean attribute that we can set through a checkbox displayed in the tree item itself.

I have a selection handler to do some stuff on my tree which gets called on click on every tree items.

What I want to do, is to prevent selection event to firing up when I'm clicking on the checkboxes ...

However, checkboxes don't have a SelectionHandler, so I tried to put a ClickEventHandler with event.stopPropagation(), but SelectionHandler is still getting called ...

EDIT: actually SelectionHandler is getting fired before ClickEventHandler anyway ...

Thanks in advance

You might consider following this method provided in the GWT documentation here . That should do the bit what you are interested in.

尝试为复选框使用单独的单击处理程序,并在其后使用event.StopProgation()以防止事件冒泡。

为了在GWT中从孩子的事件停止传播到父母,您需要使用

event.stopPropagation();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM