1

I have a dockable window with a 2 buttons that call 2 different tools (Draw Marker and Select Features), What i want to happen is when the user clicks on the relevant button on the dockable window and then clicks on the map, a onMouseUp event is called and it runs code i need to run.

Where does the onMouseUp event need to be placed so this can be done?

1

Although this is not using a dockable window, I do have an addin project where I have a form with buttons on it to draw different shapes on the maps (DrawFeatures). I also have a separate tool (DrawTool) in the project that does all the interaction with the map.

In the DrawFeatures code, the button click subroutine sets the current tool the DrawTool

Dim pUID As New ESRI.ArcGIS.esriSystem.UID
Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem

pUID.Value = My.ThisAddIn.IDs.DrawTool
pCommandItem = m_application.Document.CommandBars.Find(pUID, False, False)

m_application.CurrentTool = pCommandItem

And here's what the DrawTool code looks like

Public Class DrawTool
Inherits ESRI.ArcGIS.Desktop.AddIns.Tool

'Public LineType As String
Private m_LineFeedback As ESRI.ArcGIS.Display.INewBezierCurveFeedback = Nothing
Private graphicsContainer As ESRI.ArcGIS.Carto.IGraphicsContainer

Public Sub New()

End Sub

Protected Overrides Sub OnUpdate()

End Sub

Protected Overrides Sub OnMouseDown(ByVal arg As ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs)
    MyBase.OnMouseDown(arg)

//code to do all the drawing

End Sub

Protected Overrides Sub OnMouseMove(arg As ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs)
    MyBase.OnMouseMove(arg)

    Try
        If m_LineFeedback IsNot Nothing Then
            Dim pPoint As ESRI.ArcGIS.Geometry.IPoint = My.ArcMap.Document.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y)

            m_LineFeedback.AddPoint(pPoint)

        End If

    Catch ex As Exception
        System.Windows.Forms.MessageBox.Show(ex.ToString)
    End Try

End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.