0

How to cancel event

asked 2008-06-12 08:32:34 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5025714

By: troum

There is a button inside listcell. Both elements have onClick event listener.
Problem is that I can't stop propagation button onClick event to cells's event listener. Event.stopPropagation() method doesn't help because event listeners work in different threads.

<window id="test" title="test" border="normal" height="100%">
<listbox width="400px">
<listhead>
<listheader label="1" />
<listheader label="2" />
</listhead>
<listitem>
<listcell span="2" use="org.zkoss.test.TestCell">
<button label="Click" use="org.zkoss.test.TestButton"/>
</listcell>
</listitem>
</listbox>
</window>

public class TestButton extends Button {

public TestButton() {
super();

addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
Messagebox.show("Buttons's event");
//event.stopPropagation();
}
});
}
}

public class TestCell extends Listcell {

public TestCell() {
super();

addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
Messagebox.show("Cell's event");
}
});
}
}

Can anybody prompt solution?
Thanks
Sergey

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2008-06-12 09:44:56 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5025879

By: robbiecheng

Hi Sergey,

Please refer to http://www.zkoss.org/doc/devguide/ch05s02s06.html

/robbie


link publish delete flag offensive edit

answered 2008-06-12 09:51:37 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5025902

By: troum

hi Robbie, that's just the point that stopPropagation() method doesn't help.
Event still fired for cell element. But processing in another thread

link publish delete flag offensive edit

answered 2008-06-12 10:43:36 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5026021

By: robbiecheng

Hi Sergey,

I am sorry to tell you that this is a bug, please follow this tracker,
https://sourceforge.net/tracker/index.php?func=detail&aid=1991806&group_id=15276
2&atid=785191

/robbie

link publish delete flag offensive edit

answered 2008-06-12 10:46:24 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5026030

By: troum

thanks for help

link publish delete flag offensive edit

answered 2008-06-12 12:24:52 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5026196

By: troum

I've found very uncomfortable solution:

button event listener sends new onUser event to cell (by Events.sendEvent).
This event will be fired before onClick event on cell side. Therefore there is a ability to stop process onClick event.


link publish delete flag offensive edit

answered 2008-06-13 00:42:38 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5027790

By: robbiecheng

Hi Sergey,

Here is a good news for you, the bug has been fixed.
Please download the latest freshly of ZK 3.0.6

Or you could refer to,
https://sourceforge.net/tracker/?func=detail&atid=785191&aid=1991859&group_id=15
2762

/robbie

link publish delete flag offensive edit

answered 2012-03-08 12:27:26 +0800

ZazzaZ gravatar image ZazzaZ
9

Hi,
this is Aldo from Italy and my firm uses Zk for a large variety of products.
I have the problem that is listed in this thread, I have a Checkbox and a Radio in a ListItem.
If I click on the Radio or on the Checkbox and I stop the event propagation (in the handler event.stopPropagation();)
the event is still fired to the parent container, the listitem.
I'm using zk 5 and this bug should be fixed since 3.0.6, isn't it?

The only way I can get it work is registering a client side method to handle the client:onClick on the zul file and
make that method fail (since event.stopPropagation() doesnt't work).

It is a very dirty solution but it is the one I've found. But it is a non-solution.

Any ideas?!?!

Thanks in advance!

Aldo

link publish delete flag offensive edit

answered 2012-04-26 07:57:51 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

hi,
I think you misunderstand behavior of event.stopPropagation(). It stops the event to be handled by following event handle that register on the same component. It does not stop parent component's event propagation.

so, in your case, stop event for checkbox doesn't stop event for listitem, either.

link publish delete flag offensive edit

answered 2012-04-30 16:20:35 +0800

ZazzaZ gravatar image ZazzaZ
9

So, how it is possible to stop event bubbling?

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-06-12 08:32:34 +0800

Seen: 652 times

Last updated: Apr 30 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More