How to prevent select action on a click


I’m trying to implement a click handler on a Panel inside a node, that when I click on it will prevent the event of selection on the parent node.

Basically something like e.stopPropagation of JavaScript.
I was able to go over all the selected parts and make them not selected, but it’s not enough since I have another piece of code that listens to the ChangedSelection event and it’s being called.

Not sure this is possible in an easy way since I noticed that my ChangedSelection handler is being called before the click handler…

Any ideas?


Yes, that’s right – the node is selected even before the click event handler is called. The expectation is usually the case that the click functionality might depend on the node being selected.

I’ll see if there’s a solution.

By the way, for completeness I might as well say that the natural thing to try is to set e.handled = true in your event handler, since that will prevent the click event from going up the visual tree to containing Panels, all the way up to the Node.

As you discovered, the Node is already selected at the time the click event happens. This is what the ClickSelectingTool does. So one possibility is to override method(s) on that tool. Instead I will suggest an alternative.

The easiest work-around might be to set: isActionable: true on the GraphObject that also has a click event handler defined on it. This causes the ActionTool to handle the mouse events, including the click, rather than the ClickSelectingTool.

Interesting. I will give it a try next time I’m at work.