gwentech
Topic Author
Posts: 5
Joined: 29 Oct 2013, 20:36

Stopping Broadcast of FingerDown when menu item is selected

17 Dec 2013, 18:13

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.
 
User avatar
jsantos
Site Admin
Posts: 4266
Joined: 20 Jan 2012, 17:18
Contact:

Re: Stopping Broadcast of FingerDown when menu item is selec

17 Dec 2013, 20:51

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.
 
gwentech
Topic Author
Posts: 5
Joined: 29 Oct 2013, 20:36

Re: Stopping Broadcast of FingerDown when menu item is selec

19 Dec 2013, 14:05

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!
 
User avatar
jsantos
Site Admin
Posts: 4266
Joined: 20 Jan 2012, 17:18
Contact:

Re: Stopping Broadcast of FingerDown when menu item is selec

19 Dec 2013, 14:56

Thanks for reporting back!

My comment about the HitTest was doing something similar to this
HitTestResult hit = VisualTreeHelper.HitTest(root, mousepos);
if (hit.visualHit == _myCanvas)
{
}
Do you mean that the function was always returning null to you?

Who is online

Users browsing this forum: No registered users and 3 guests