tags:

views:

703

answers:

2

What is the thinking/philosophy behind having tunneling before Bubbling and not viceversa .

+1  A: 

This gives the container, for example, the power to see an event before its children. This is useful in many cases, as e.g. disabling children, hover animations, drag'n'drop, selecting a parent container before continuing checking/clicking the child widget etc.

In other words, IMO it's easier to create a new container for a custom UI behavior and preview the events (tunneling) that go to stock widgets, than to create custom widgets and using a stock container (bubbling).

Vlagged
Dont feel 100% with the container exampletaking an example I understand :) , if i have an image on a button , wouldnt i want the button to get the mousedownevent for click processing rather than the other way ? so button been composed of image bubbling should be first rather than tunnelingOn similar lines when would tunneling make sense before bubbling
AB
If you have an image within a button and you click in the image area, the button will receive the tunneled event first ('PreviewMouseDown'), while the image will receive the bubbled event first. Since tunneling occurs before bubbling, you just need to implement the handler on the button, regardless of its content.
Vlagged
+1  A: 

Tunneling is before bubbeling because event handlers are in the element tree root.

This is well explained here in "Routing strategies"

rockeye
thanks for the doc mate , was helpful
AB