Disable the Data Frame Context menu when you right-click on a map in ArcMap

1150
2
Jump to solution
07-03-2013 11:34 AM
IanKramer
New Contributor III
Hi,
I have written a tool in my editor extension add-in that allows the user to select a feature from one layer with a left click and then select another feature with a right click, which then performs some analysis.  However, when the user right-clicks, I get the Data Frame Context menu, which I want to disable.  Does anybody know how to disable or suppress this popup menu from appearing on a right-click?  My code is executed on the MouseDown event and I don't have any code in the MouseUp event for the tool.  I have found the UID for the Data Frame Context Menu, but I have not seen any methods or properties that allow me to disable it.

Thanks!

Ian
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Ian,
In your add-in tool you can suppress the context menu by overriding the call to OnContextMenu and returning 'true'.

  public class Tool1 : ESRI.ArcGIS.Desktop.AddIns.Tool   {     public Tool1()     {     }      protected override bool OnContextMenu(int x, int y)     {       //return base.OnContextMenu(x, y);       return true;     }      protected override void OnMouseDown(MouseEventArgs arg)     {       System.Diagnostics.Debug.WriteLine(arg.Button.ToString());      }      protected override void OnUpdate()     {       Enabled = ArcMap.Application != null;     }

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable
Ian,
In your add-in tool you can suppress the context menu by overriding the call to OnContextMenu and returning 'true'.

  public class Tool1 : ESRI.ArcGIS.Desktop.AddIns.Tool   {     public Tool1()     {     }      protected override bool OnContextMenu(int x, int y)     {       //return base.OnContextMenu(x, y);       return true;     }      protected override void OnMouseDown(MouseEventArgs arg)     {       System.Diagnostics.Debug.WriteLine(arg.Button.ToString());      }      protected override void OnUpdate()     {       Enabled = ArcMap.Application != null;     }
0 Kudos
IanKramer
New Contributor III
Thank you!  That worked.
0 Kudos