AnsweredAssumed Answered

cannot find OnClick() method in Tool

Question asked by MariaMaldini on Jan 20, 2015
Latest reply on Jan 23, 2015 by MariaMaldini

I am developing a Tool using Add-Ins in order to get the coordinate where user clicks on map ( through OnMouseDown event), but I want to do some operations before getting coordinates in another method. I try to explain my problem with a simple example. for example, I want to see a message box that will be called from a method ( msg method) and then user click on map and get coordinates using OnMouseDown event. my problem is that the first time that i click on tool's icon i see a message box (" hello") but the second time that i click on tool's icon, it does not show message box and tool just call OnMouseDown event.

( as i told, i do not want to have message box in  OnMouseDown event)

please help, thanks in advance

 

 

using System;

using System.Collections.Generic;

using System.Text;

using System.IO;

using System.Windows.Forms;

 

namespace msg

{

    public class msg : ESRI.ArcGIS.Desktop.AddIns.Tool

    {

        public msg()

        {

            MessageBox.Show("hello");

        }

 

        protected override void OnMouseDown(MouseEventArgs arg)

        {

            //get map coordinate

        } 

 

        protected override void OnUpdate()

        {

            Enabled = ArcMap.Application != null;

        }

    }

}

Outcomes