Creating Accelerator Keys


In the "Customizing Toolbars" section earlier in this chapter, you saw how to add shortcut keys by using the Customize dialog box. If you prefer, you can also add shortcut keys directly into a menu file. The shortcut keys are called accelerators in the menu file.

To add accelerator key definitions directly to a menu file, you need to become familiar with some additional code. The following is an example of what you can add to the Mymenu.mnu file to define a set of accelerator keys:

***ACCELERATORS
[CONTROL+SHIFT+"E"]endp
[CONTROL+SHIFT+"X"]int
ID_1breakat [CONTROL+SHIFT+"B"]

The ***ACCELERATORS line at the top is the group heading, similar to the ***HELPSTRINGS heading in that it defines the beginning of the section. This is followed by the accelerator descriptions.

Two methods are shown in the previous example for defining an accelerator key. The first two bracketed text items follow the format you've already seen for the pull-down menu. But instead of the menu text in square brackets, you see the keys required to invoke the action that follows the brackets. So in the first line

[CONTROL+SHIFT+"E"]endp

the CONTROL+SHIFT+"E" tells AutoCAD to enter the Endpoint Osnap ( endp ) whenever the Ctrl+Shift+E key combination is pressed. Notice that the E is in quotation marks and that all the characters are uppercase. Follow this format for quotation marks and capitalization when you create your own accelerator keys.

A second method is shown in the third line:

ID_1breakat [CONTROL+SHIFT+"B"]

Here, the ID_1breakat is used to associate a key combination with a menu option, not unlike the way it is used to associate a menu item with a help string. This line tells AutoCAD to issue the Breakat macro listed earlier in the menu whenever the Ctrl+Shift+B key combination is pressed.

You can use either Ctrl or Shift individually or together in combination with most keys on your keyboard, including the function keys. You can also assign keys without the Ctrl or Shift options. Note that the function keys and the Esc key are already defined, so take care that you don't redefine them unless you really want to. Table 20.1 contains a list of some of the special keys you can define and how you need to specify them in the menu file.

Warning  

Although you can use the F1 and Esc keys for accelerator keys, their use is discouraged because they serve other functions for both Windows and AutoCAD.

Table 20.1: Key Names to Use in Your Accelerator Key Definitions

Key

Format Used in AutoCAD Menu

Numeric keypad

"NUMPAD0" through "NUMPAD9"

Ins

"INSERT"

Del

"DELETE"

Function keys

"F2" through "F12"

Up arrow

"UP"

Down arrow

"DOWN"

Left arrow

"LEFT"

Right arrow

"RIGHT"




Mastering AutoCAD 2005 and AutoCAD LT 2005
Mastering AutoCAD 2005 and AutoCAD LT 2005
ISBN: 0782143407
EAN: 2147483647
Year: 2004
Pages: 261
Authors: George Omura

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net