Stopping Broadcast of FingerDown when menu item is selected
While using with Unity, I have a simple pull-down menu only. I have a script looking for FingerDown events for the rest of the canvas (think of it as a paint application). When I click on the menu, FingerDown still fires on the canvas. How do I stop that so that the FingerDown is 'consumed' when clicking the menu?
Thanks in advance.
Thanks in advance.
Re: Stopping Broadcast of FingerDown when menu item is selec
Our controls ignore Touch events on purpose. That way they can be inserted in touch aware containers. This allows for example having buttons inside a scrollviewer. Buttons can be clicked and at the same time the scrollviewer support touch manipulations.
This separation between Mouse and Touch can be tricky. I don't know how WPF solves your scenario (I will investigate it as soon as possible to see if we are doing some different and fix it) but for now my recommendation is that when you receive the TouchDown event detect with VisualTreeHelper.HitTest if there is a control above you and in that case ignore the event. If touch event is ignored it is converted to a Mouse Click that will be intercepted by the menu.
This separation between Mouse and Touch can be tricky. I don't know how WPF solves your scenario (I will investigate it as soon as possible to see if we are doing some different and fix it) but for now my recommendation is that when you receive the TouchDown event detect with VisualTreeHelper.HitTest if there is a control above you and in that case ignore the event. If touch event is ignored it is converted to a Mouse Click that will be intercepted by the menu.
Re: Stopping Broadcast of FingerDown when menu item is selec
OK, I wasn't able to get Hittest() to work as it was always returning false. I'm sure I was just doing something wrong in usage.
In either case, I implemented the Noesis's menu events 'MouseEnter' and 'MouseLeave', setting\clearing a singleton variable to determine whether user was accessing the menu or not. That seems to work so far. Hoping this helps someone else.
Thanks!
In either case, I implemented the Noesis's menu events 'MouseEnter' and 'MouseLeave', setting\clearing a singleton variable to determine whether user was accessing the menu or not. That seems to work so far. Hoping this helps someone else.
Thanks!
Re: Stopping Broadcast of FingerDown when menu item is selec
Thanks for reporting back!
My comment about the HitTest was doing something similar to this
Do you mean that the function was always returning null to you?
My comment about the HitTest was doing something similar to this
Code: Select all
HitTestResult hit = VisualTreeHelper.HitTest(root, mousepos);
if (hit.visualHit == _myCanvas)
{
}
Who is online
Users browsing this forum: No registered users and 3 guests