Select to view content in your preferred language

Map Touch Tap To Mouse Click?

9852
21
01-12-2011 09:33 AM
RyanCoodey
Frequent Contributor
I am new to working with touch screens but we have a few and the touch gesters work great such as pan and zoom.  We have a toolbar with a few tools such as an identify tool and a measure tool, etc... these are listening for the mouse click event on the map... 

What is the best way to handle both touch taps and mouse clicks?

1) For each tool we created do I need to handle both the MouseClick and the TouchUp events?
2) This wont work for the measure action though because that is an action (which has the clicking embedded), so how do we use the measure action with touch?

Thanks a lot for any info!

*EDIT*
So in I tried this in one of my tools:
        map.MapGesture += Identify_MapGesture;
        ...

        protected void Identify_MapGesture(Object sender, ESRI.ArcGIS.Client.Map.MapGestureEventArgs e)
        {
            if(e.Gesture == GestureType.Tap)
            {
                ESRI.ArcGIS.Client.Map.MouseEventArgs mouseEventArgs = new ESRI.ArcGIS.Client.Map.MouseEventArgs();
                mouseEventArgs.MapPoint = e.MapPoint; 
              Identify_MouseClick(sender, mouseEventArgs);
            }
        }

And it works pretty good...
0 Kudos
21 Replies
RobertDriessen
Deactivated User
I am having this exact same problem.  The MeasureAction works with mouse clicks but NOT finger touches.  It more than a year later with a newer version (10.2) but still seems to be a problem.  Has anyone solved this?  ESRI?
0 Kudos
FredrikJohansson
New Contributor
I made a workaround for the missing TouchTap, using the TouchDown and TouchUp event. If measuring the time difference between TouchDown and TouchUp you can call your own mapControl_TouchTap "Event" if the time is short enough (in my case <500ms). Works well for me when tapping features anyway. See code below:

        private DateTime m_LastTouchDownTime;
        private void mapControl_TouchDown(object sender, TouchEventArgs e)
        {
            m_LastTouchDownTime = DateTime.Now;
        }

        private void mapControl_TouchUp(object sender, TouchEventArgs e)
        {
            if (new TimeSpan(DateTime.Now.Ticks - m_LastTouchDownTime.Ticks).TotalMilliseconds < 500)
            {
                mapControl_TouchTap(sender, e);
            }
        }

        private void mapControl_TouchTap(object sender, TouchEventArgs e)
        {
            if ((bool)EditingToolbar.IdentifyButton.IsChecked)
            {
                ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = mapControl.ScreenToMap(e.GetTouchPoint(mapControl).Position);
                IdentifyFeatures(mapPoint);
            }
        }
0 Kudos