Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to stop mouse event propagation #999

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

sliekens
Copy link
Contributor

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.

@sliekens
Copy link
Contributor Author

Last minute change: also stop propagating other mouse inputs like MouseMove from Panel headers

after.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant