ArcObjects Library Reference  (SystemUI)    

ITool.OnMouseDown Method

Occurs when a mouse button is pressed when this tool is active.

[Visual Basic 6.0]
Sub OnMouseDown(
    ByVal button As Long, _
    ByVal shift As Long, _
    ByVal x As Long, _
    ByVal y As Long _
)
[Visual Basic .NET]
Public Sub OnMouseDown ( _
    ByVal button As Integer, _
    ByVal shift As Integer, _
    ByVal x As Integer, _
    ByVal y As Integer _
)
[C#]
public void OnMouseDown (
    int button,
    int shift,
    int x,
    int y
);
[Java]
public void onMouseDown (
    int button,
    int shift,
    int x,
    int y
)
throws
    IOException,
    AutomationException
[C++]
HRESULT OnMouseDown(
  long button,
  long shift,
  long x,
  long y
);
[C++]

Parameters

button [in]

  button is a parameter of type long

shift [in]

  shift is a parameter of type long

x [in]

  x is a parameter of type long

y [in]

  y is a parameter of type long

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

button specifies which mouse button is pressed. The button argument is a bit field. Some, all, or none of the bits can be set indicating that some, all, or none of the mouse buttons are pressed. The values for button are as follows:

      1   Left button
      2   Right button
      3   Left and Right buttons
      4   Middle button
      5   Left and Middle buttons
      6   Right and Middle buttons
      7   All buttons

Shift indicates whether the Shift key, Ctrl key, or Alt key is pressed when the mouse button is pressed. The Shift argument is a bit field. Some, all, or none of the bits can be set indicating that some, all, or none of the keys are pressed. The values for Shift are as follows:

      0   No key pressed
      1   Shift key pressed
      2   Ctrl key pressed
      3   Shift and Ctrl keys pressed
      4   Alt key pressed
      5   Shift and Alt keys pressed
      6   Ctrl and Atl keys pressed
      7   Shift, Ctrl, and Alt keys pressed

X is the X coordinate, in device units, where the mouse button was pressed.

Y is the Y coordinate, in device units, where the mouse button was pressed.

Remarks

When implementing ITool to create a custom tool, write the code that performs the action when the left mouse button is pressed when this tool is the active tool in the OnMouseDown method.

[Visual Basic 6.0]

Your class code could include something like the following code.

Private Sub ITool_OnMouseDown(ByVal Button As Long, _
                              ByVal Shift As Long, _
                              ByVal X As Long, ByVal Y As Long)
  ' Add some code to do some action when the mouse button is pressed.
  ' This example displays the X and Y coordinates of the 
  ' left mouse button click in the statusbar message in ArcMap.
  ' X and Y are passed in as arguments to this sub procedure.
 
  ' Check to see if left button is pressed
  If Button = 1 Then    
    ' Convert x and y to map units. m_pApp is set in ICommand_OnCreate.
    Dim pPoint As IPoint
    Dim pMxApp As IMxApplication
    Set pMxApp = m_pApp
    Set pPoint = pMxApp.Display.DisplayTransformation.ToMapPoint(x, y)
    ' Set the statusbar message.
    m_pApp.StatusBar.Message(0) = Str(pPoint.X) & "," & Str(pPoint.Y)
  End If
End Sub

See Also

ITool Interface

Example

ITool Example

 


Feedback Send feedback on this page