Go to: Synopsis. Return value. Flags. MEL examples.

Synopsis

assignCommand [-addDivider string] [-altModifier] [-annotation string] [-command script] [-commandModifier] [-ctrlModifier] [-data1 string] [-data2 string] [-data3 string] [-delete int] [-dividerString string] [-factorySettings boolean] [-index int] [-keyString string] [-keyUp boolean] [-name] [-numDividersPreceding int] [-numElements] [-optionModifier] [-sortByKey boolean] [-sourceUserCommands] int

assignCommand is undoable, queryable, and editable.

This command allows the user to assign hotkeys and manipulate the internal array of named command objects. Each object in the array has an 1-based index which is used for referencing. Under expected usage you should not need to use this command directly as the Hotkey Editor may be used to assign hotkeys.

Return value

None

In query mode, return type is based on queried flag.

Flags

addDivider, altModifier, annotation, command, commandModifier, ctrlModifier, data1, data2, data3, delete, dividerString, factorySettings, index, keyString, keyUp, name, numDividersPreceding, numElements, optionModifier, sortByKey, sourceUserCommands
Long name (short name) Argument types Properties
-index(-i) int edit
The index of the object to operate on. The index value ranges from 1 to the number of name command objects.
-keyString(-k) string queryedit
This specifies a key to assign a command to in edit mode. In query mode this flag returns the key string, modifiers and indicates if the command is mapped to keyUp or keyDown.
-altModifier(-alt) edit
This flag specifies if an alt modifier is used for the key.
-optionModifier(-opt) edit
This flag specifies if an option modifier is used for the key.
-ctrlModifier(-ctl) edit
This flag specifies if a ctrl modifier is used for the key.
-commandModifier(-cmd) edit
This flag specifies if a command modifier is used for the key. This is only available on systems which support a separate command key.
-keyUp(-kup) boolean edit
This flag specifies if the command is executed on keyUp or keyDown.
-annotation(-ann) string queryedit
The string is the english name describing the command.
-command(-c) script queryedit
This is the command that is executed when this object is mapped to a key or menuItem.
-name(-n) query
The name of the command object.
-data1(-da1) string queryedit
Optional, user-defined data strings may be attached to the nameCommand objects.
-data2(-da2) string queryedit
Optional, user-defined data strings may be attached to the nameCommand objects.
-data3(-da3) string queryedit
Optional, user-defined data strings may be attached to the nameCommand objects.
-numElements(-num) query
This command returns the number of namedCommands in the system. This flag doesn't require the index to be specified.
-delete(-d) int edit
This tells the Manager to delete the object at position index.
-sortByKey(-sbk) boolean queryedit
This key tells the manager to sort by key or by order of creation.
-factorySettings(-fs) boolean edit
This flag sets the manager back to factory settings.
-addDivider(-ad) string edit
Appends an "annotated divider" item to the end of the list of commands.
-dividerString(-ds) string query
If the passed index corresponds to a "divider" item, then the divider's annotation is returned. Otherwise, a null string is returned.
-numDividersPreceding(-ndp) int query
If the index of a namedCommand object C is passed in, then this flag returns the number of "divider" items preceding C when the namedCommands are sorted by category.
-sourceUserCommands(-suc) edit
This command sources the user named command file.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

// Print out all the names of the named command objects and the
// hotkey attached to them.
//
int $index, $count = `assignCommand -query -numElements`;
string $keyString[];
print ("There are " + $count + " named command objects.\n");
for ($index = 1; $index <= $count; $index++) {
    print (`assignCommand -query -name $index` + " (");
    $keyString = `assignCommand -query -keyString $index`;
    if (0 < size($keyString)) {
        if ("1" == $keyString[2]) {
            print ("Ctrl+");
        }
        if ("1" == $keyString[1]) {
            print ("Alt+");
        }
        if ("1" == $keyString[4]) {
            print ("Command+");
        }
        print ($keyString[0]);
        if ("1" == $keyString[3]) {
            print (" Release");
        }
    }
    print (")\n");
}