要通过 AutoCAD ActiveX/VBA 为菜单项指定快捷键,请使用给定菜单项的特性。Label 若要指定加速键,请在要用作加速键的字符正前方的标签中插入与号 (&) 的 ASCII 等效项。例如,标签 Chr(Asc(“&”)) + “Edit” 将显示为“Edit”,字符“E”用作快捷键。 向菜单添加加速键本示例为“TestMenu”和“Open”菜单添加快捷键。“s”用作“TestMenu”菜单的加速键,“O”用作“打开”菜单的加速键。 Sub Ch6_AddAMenuItem()
Dim currMenuGroup As AcadMenuGroup
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' Create the new menu
Dim newMenu As AcadPopupMenu
Set newMenu = currMenuGroup.Menus.Add _
("Te" + Chr(Asc("&")) + "stMenu")
' Add a menu item to the new 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 = newMenu.AddMenuItem _
(newMenu.count + 1, Chr(Asc("&")) _
+ "Open", openMacro)
' Display the menu on the menu bar
newMenu.InsertInMenuBar _
(ThisDrawing.Application.menuBar.count + 1)
End Sub
相关概念 |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 08:46
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.