Add Entries to the Right-Click Menu

AutoCAD ActiveX

 
Add Entries to the Right-Click Menu
 
 
 

The right-click menu, or shortcut menu, is a special menu included in the AutoCAD base menu group. This menu appears when the user holds SHIFT and clicks the right mouse button.

AutoCAD finds the shortcut menu by looking in the base menu group for a menu with the ShortcutMenu property equal to TRUE. You can add new menu items to the shortcut menu by following the steps listed in Add New Menu Items to a Menu.

New menu groups may or may not have a shortcut menu available. To create a shortcut menu for a menu group, follow the guidelines listed in Create New Menus, and use POP0 as the label for the new menu.

Add a menu item to the end of the right-click menu

This example adds the menu item “OpenDWG” to the end of the right-click menu.

Sub Ch6_AddMenuItemToshortcutMenu()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
 ' Find the shortcut menu and assign it to the
 ' shortcutMenu variable
 Dim scMenu As AcadPopupMenu
 Dim entry As AcadPopupMenu
 For Each entry In currMenuGroup.Menus
 If entry.shortcutMenu = True Then
 Set scMenu = entry
 End If
 Next entry
 ' Add a menu item to the shortcut menu
 Dim newMenuItem As AcadPopupMenuItem
 Dim openMacro As String
 ' Assign the macro the VBA equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "
 Set newMenuItem = scMenu.AddMenuItem _
 ("", Chr(Asc("&")) _
 + "OpenDWG", openMacro)
End Sub