Class ShortcutTable

3DS Max Plug-In SDK

Class ShortcutTable

See Also: Structure ShortcutDescription, Class ClassDesc, Class ShortcutOperation, Class ShortcutCallback.

class ShortcutTable

Description:

This class is available in release 3.0 and later only.

This class represents a table of accelerators used by plug-ins. A plug-in can have various keyboard shortcut tables it uses. These tables hold a name that appears in the Preference Settings dialog / Keyboard tab / Plug-Ins dropdown list, a unique ID for the table, the number of shortucts in the table, and storage for each of the Shortcut operations.

The number and a pointer to the 'i-th' shortcut table are returned by the methods ClassDesc::NumShortcutTables() and ClassDesc::GetShortcutTable(int i).

For an example of using this mechanism see the code in the directory \MAXSDK\SAMPLES\MODIFIERS\FFD.

All methods of this class are implemented by the system.

Methods:

Prototype:

ShortcutTable(ShortcutTableId id, TSTR& name, HACCEL hDefaults, int numIds, ShortcutDescription* pOps, HINSTANCE hInst);

Remarks:

Constructor. The data members are initialized to the values passed. A typical call to this constructor looks like this:

const ShortcutTableId kNURBSShortcuts = 0x34f274e4;

#define NumElements(array) (sizeof(array) / sizeof(array[0]))

 

ShortcutTable *GetShortcuts() {

TSTR name = GetString(IDS_JUST_NURBS);

HACCEL hAccel = LoadAccelerators(hInstance,

MAKEINTRESOURCE(IDR_NURBS_SHORTCUTS));

int numOps = NumElements(spShortcuts);

ShortcutTable* pTab;

pTab = new ShortcutTable(kNURBSShortcuts,

name, hAccel, numOps, spShortcuts, hInstance);

return pTab;

}

Parameters:

ShortcutTableId id

This is the unique ID for the table. Typically developers use 'half' a ClassID as output by the ClassID Generator program. See the example above. Note: typedef long ShortcutTableId;

TSTR& name

This is the name for the table which appears in the 3ds max UI in the Files / Preference Settings / Keyboard tab / Plug-In drop down list.

HACCEL hDefaults

This is the handle to the default keyboard accelerators. When a plug-in registers a shortcut table it needs to give the system a table of default shortcut assignments. It doesn't need to give all the operations default assignments, but it does need to give it a table of defaults. This table could be empty. This table is also used to implement the "Reset Category" button on the keyboard preferences dialog.

int numIds

This is the size of the array of shortcut descriptors specified below.

ShortcutDescription* pOps

Points to the array of shortcut descriptors.

HINSTANCE hInst

The Dll instance handle of the plug-in.

Prototype:

~ShortcutTable();

Remarks:

Destructor. Any memory allocated by the constructor is freed here.

Prototype:

HACCEL GetHAccel();

Remarks:

Returns the handle of the currently active keyboard accelerator table.

Prototype:

void SetHAccel(HACCEL hAccel);

Remarks:

Sets the currently active keyboard accelerator table.

Parameters:

HACCEL hAccel

The handle to use.

Prototype:

HACCEL GetDefaultHAccel();

Remarks:

Returns the handle of the table of default shortcut assignments that are registered in the constructor for ShortcutTable.

Prototype:

TSTR& GetName();

Remarks:

Returns the name of the table to use in the Preference Settings / Keyboard tab / Plug-Ins drop down list.

Prototype:

ShortcutTableId GetId();

Remarks:

Returns the unique identifier of the table. Note: typedef long ShortcutTableId;

Prototype:

int Count();

Remarks:

Returns the number of shortcut operations in the table.

Prototype:

void DeleteThis();

Remarks:

Deletes this instance of the class.

Prototype:

ShortcutOperation& operator[](int i);

Remarks:

Provides access to the table of shortcut descriptions.

Parameters:

int i

The zero based index of the entry to get.