Add the ability to stop mouse event propagation #999
+63
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the ability to stop click events (or any other mouse event) from propagating.
private void OnClick(object sender, MouseEventArgs e) { Console.WriteLine("Click was handled here"); + e.StopPropagation(); }
This is useful when a click should be handled by a node and then stopped without propagating all the way down to leaf nodes.
An example where this is useful is in scrollable accordions. Previously, clicking the header to collapse the panel would also propagate the click to controls behind the header.
The fix for clicks on Panel headers is included in the PR.
Before
before.mp4
After
after.mp4
Discussion Reference
https://discord.com/channels/531175899588984842/536970543736291346/1330148945749475358
Is this a breaking change?
I don't expect this change to break any modules, although I marked 2 methods as Obsolete because they did not support this change. I added new overloads to support this change. The old methods will continue to work, just without the ability to stop propagation, i.e. calling
StopPropagation()
will do nothing.