Phantom snap tip that stays after mouse cursor moves away.

Discussion created by huangs3 on Feb 7, 2014
Latest reply on Feb 10, 2014 by huangs3
Hi Everybody:

    I am trying to build a tool that uses the ArcGIS snapping. In general it works well, but there is a display issue that I don't know how to handle.

    In ArcMap I created a context menu command to activate the tool, such that user can right-click on map, select the command to get the tool activated, and the mouse cursor is on the map right-after. If right-after (say, within 0.1 second) activating the tool my mouse cursor is on some feature edge or vertices that can trigger a snap tip, that snap tip will not disappear even if I move the cursor away, regardless the mouse cursor is getting other snap tip or not. See the attached figure.


    Once that strange snap shows up, the way to remove it is to eigher refresh the map or deactivate the tool.

    Why does this happen? Is there any way to fix it?

Below are the code I wrote in the tool to handle the snapping.

        /// <summary>
        /// Triggered when the tool is clicked.
        /// </summary>
        public override void OnClick()
            SharedState sharedData = SharedState.GetInstance();
            m_SnappingEnv = sharedData.ArcApp.FindExtensionByName("ESRI Snapping") as ISnappingEnvironment;
            m_Snapper = m_SnappingEnv.PointSnapper;
            m_SnappingFeedback = new SnappingFeedbackClass();
            m_SnappingFeedback.Initialize(sharedData.ArcApp, m_SnappingEnv, true);

        public override void OnMouseMove(int Button, int Shift, int X, int Y)
            base.OnMouseMove(Button, Shift, X, Y);

            //Convert the point from pixels to map units.
            IPoint mapPoint = null;
            mapPoint = QueryMapPoint((m_application.Document as IMxDocument).ActivatedView.ScreenDisplay, X, Y);
            mapPoint.Z = 0;

            //Test the location against the snap environment.
            if (m_CurrentMousePoint != null)
            ISnappingResult snapResult = m_Snapper.Snap(mapPoint);
            if (snapResult != null)
                m_CurrentMousePoint = snapResult.Location;
                m_CurrentMousePoint = mapPoint;

            //Update the snapping feedback.
            m_SnappingFeedback.Update(snapResult, 0);