Select to view content in your preferred language

MouseDown pass through of right click

835
3
10-18-2010 08:47 AM
RichardFairhurst
MVP Alum
I have created a UIToolControl in VBA that I would like to activate only if the left mouse button is clicked within the map.  However, if the right mouse button is clicked I would like the normal ArcMap context menu to be activated.  I know how to test for the left button event, but if all I do is determiine that another button was clicked and exit the sub, no context menu is activated.

Do I have to explicitly call the context menu when the right mouse button is clicked or can I somehow pass the right click event to ArcMap?  What do I need to do to get the right mouse click to activate the normal ArcMap context menu when my tool is active?  Thanks.
0 Kudos
3 Replies
NeilClemmons
Honored Contributor
In the code editor, choose ContextMenu from the right-hand dropdown list and have it return False.
0 Kudos
RichardFairhurst
MVP Alum
In the code editor, choose ContextMenu from the right-hand dropdown list and have it return False.


Thanks for the reply.  I added the code below but the behavior of the tool has not changed and the code below is not fired.  I still do not get a context menu if the right button is clicked.  What am I missing?

Private Function UIToolControl1_ContextMenu(ByVal x As Long, ByVal y As Long) As Boolean
  UIToolControl1_ContextMenu = False
End Function
0 Kudos
RichardFairhurst
MVP Alum
Neil thanks for the suggestion.  I got the ContextMenu to work after looking at some of your other older posts.  In addition to setting the ContextMenu value to False I also had to alter the Mousedown behavior to detect the right-click button and send the clicked coordinates to the ContextMenu of the tool.  So the minimum code required to get the behavior I wanted is:

Private Function UIToolControl1_ContextMenu(ByVal x As Long, ByVal y As Long) As Boolean
  UIToolControl1_ContextMenu = False
End Function

Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
  If button = 2 Then
    UIToolControl1_ContextMenu x, y
  ElseIf button = 1 Then
    ' Whatever the tool does
  End If
End Sub
0 Kudos