Go to: Synopsis. Flags. Return value. MEL examples.
hotkeyCheck [-altModifier] [-commandModifier] [-ctrlModifier] [-keyString string] [-keyString string] [-keyUp] [-optionModifier]
hotkeyCheck is undoable, queryable, and editable.
This command checks if the given hotkey is mapped to a nameCommand
object. If so, the annotation of the nameCommand object is returned.
Otherwise an empty string is returned.
altModifier, commandModifier, ctrlModifier, keyString, keyString, keyUp, optionModifier
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
|
A string containing the annotation of the nameCommand object, or
an empty string.
// Create a window in which you can type a hotkey character
// and determine via the 'hotkeyCheck' command the annotation
// of the command attached.
//
string $window = `window -title "hotkeyCheck Example"`;
columnLayout -adjustableColumn true;
// A few instructions in a scrollField for the user.
//
string $instructions = ("Enter a single character in the field "
+ "below. Then press the \"Query\" button to determine "
+ "the annotation of the command attached to that hotkey.");
scrollField -text $instructions -editable false -height 120
-wordWrap true;
string $textFieldGrp = `textFieldGrp
-label "Enter a single hotkey character" -text "a"
-columnWidth2 200 50`;
// Create a couple controls for specifying modifier keys and the
// key press/release information.
//
string $checkBoxGrp = `checkBoxGrp -label "Modifiers"
-numberOfCheckBoxes 2
-labelArray2 "Ctrl" "Alt" -columnWidth3 100 75 75`;
string $radioButtonGrp = `radioButtonGrp -label "Action"
-numberOfRadioButtons 2 -select 1
-labelArray2 "Press" "Release" -columnWidth3 100 75 75`;
// Create a scroll field for printing the results.
//
string $scrollField = `scrollField -editable false -height 120
-wordWrap true`;
// Create a button for querying the hotkey.
//
button -label "Query" -command ("ExampleHotkeyCheck " + $textFieldGrp
+ " " + $checkBoxGrp + " " + $radioButtonGrp + " " + $scrollField);
showWindow $window;
// This procedure uses the 'hotkeyCheck' command to determine the
// annotation of the command attached to a hotkey.
//
global proc ExampleHotkeyCheck(
string $textFieldGrp,
string $checkBoxGrp,
string $radioButtonGrp,
string $scrollField)
{
string $result;
string $mapping;
// Get the hotkey character, modifier state and key press/release
// information from the window.
//
string $key = `textFieldGrp -query -text $textFieldGrp`;
int $ctrl = `checkBoxGrp -query -value1 $checkBoxGrp`;
int $alt = `checkBoxGrp -query -value2 $checkBoxGrp`;
int $press = `radioButtonGrp -query -select $radioButtonGrp`;
// Get the hotkey mapping taking into consideration key up or down
// and the state of the modifier keys.
//
if (1 == $press) {
if (!$ctrl && !$alt) {
$mapping = `hotkeyCheck -keyString $key`;
$result = ($key + "-Press");
} else if ($ctrl && !$alt) {
$mapping = `hotkeyCheck -keyString $key -ctl`;
$result = ("Ctrl-" + $key + "-Press");
} else if (!$ctrl && $alt) {
$mapping = `hotkeyCheck -keyString $key -alt`;
$result = ("Alt-" + $key + "-Press");
} else if ($ctrl && $alt) {
$mapping = `hotkeyCheck -keyString $key -ctl -alt`;
$result = ("Ctrl-Alt-" + $key + "-Press");
}
} else {
if (!$ctrl && !$alt) {
$mapping = `hotkeyCheck -keyString $key -keyUp`;
$result = ($key + "-Release");
} else if ($ctrl && !$alt) {
$mapping = `hotkeyCheck -keyString $key -ctl -keyUp`;
$result = ("Ctrl-" + $key + "-Release");
} else if (!$ctrl && $alt) {
$mapping = `hotkeyCheck -keyString $key -alt -keyUp`;
$result = ("Alt-" + $key + "-Release");
} else if ($ctrl && $alt) {
$mapping = `hotkeyCheck -keyString $key -ctl -alt -keyUp`;
$result = ("Ctrl-Alt-" + $key + "-Release");
}
}
// Print the results in the example window.
//
if ("" == $mapping) $mapping = "Nothing";
scrollField -edit
-text ($result + " is mapped to:\n\n" + $mapping) $scrollField;
}