Controlling Event Routing #323
Replies: 3 comments 2 replies
-
You can prevent events from bubbling up by marking them as handled. Control.onX (fun args ->
args.Handled <- true
) |
Beta Was this translation helpful? Give feedback.
-
Ahh, sure. You can do it like this https://reference.avaloniaui.net/api/Avalonia.Interactivity/Interactive/CA5C2E9F Control.init (fun control -> (I'm on my phone, can't verify) |
Beta Was this translation helpful? Give feedback.
-
I ended up solving it by checking the name of the Source.
This idea came from the docs: Where they have the following example code:
I don't like having to do the unsafe cast in F#. It feels wrong, but the |
Beta Was this translation helpful? Give feedback.
-
I'm running into a problem where elements beneath others are responding to events what I don't want them to. Based on the AvaloniaUI docs I believe what I want is direct routing (https://docs.avaloniaui.net/docs/input/routed-events#routing-strategies).
I am working in the following repo:
https://github.com/matthewcrews/AvaloniaDragAndDrop
I have a Button on a Canvas. When I right-click on the bottom the Canvas is also responding to the event even though the Canvas is below the Button. It appears that the event Tunnels down from the Parent element (the Canvas) to the Button and then Bubbles back up. What I want is to only have the Button respond to the right-click and prevent the Canvas from responding as well.
You can recreate this by cloning the repo, running the app, and then right clicking on one of the buttons. I cannot find a good example of being able to prevent this Tunneling/Bubbling routing behavior.
Beta Was this translation helpful? Give feedback.
All reactions