简体   繁体   English

GWT:如何仅在按钮位于面板中时触发按钮单击事件?

[英]GWT: How can I only trigger the button click event when the button is in a panel?

I have a button in a horizontal panel. 我在水平面板上有一个按钮。 Both the button and panel have click handler. 按钮和面板都有单击处理程序。

When I click the button, I only want the button click handler to work but not the panel one, but it triggers both. 当我单击按钮时,我只希望按钮单击处理程序起作用,而面板不希望它起作用,但是它将触发两者。

How can I avoid triggering the panel click handler? 如何避免触发面板点击处理程序?

Just call event.stopPropagation() in your click handler. 只需在点击处理程序中调用event.stopPropagation() See the answer here for an example. 有关示例,请参见此处的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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