Message 1 of 3
Override some hotkeys when using a certain tool (hotkeyCtx?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am developing a plugin in Maya (C++), and have been making some brushes.
I was able to override global Maya hotkeys to achieve different features (modify the brush size...).
I would like to override some hotkeys only when using my plugin / brushes. For that I have been looking at the Maya hotkey command with its example:
// Here's an example of how to create runtimeCommand with a certain hotkey context,
// and map it to a key.
//
// Create a command with "paintEffects" hotkey context.
//
runTimeCommand
-annotation "Modify the Brush Size for the Paint Effects Tool"
-category "MyPlugin"
-commandLanguage "mel"
-command ("print(\"Hello MyPlugin\");")
-hotkeyCtx ("MyPlugin")
ModifyBrushSize;
nameCommand
-annotation "ModifyBrushSizeNameCommand"
-sourceType "mel"
-command ("ModifyBrushSize")
ModifyBrushSizeNameCommand;
// Assign the paintEffects as a hotkey context client.
//
hotkeyCtx -type "Tool" -addClient "MyPlugin";
// Map a key to the newly created command.
// When the Paint Effects Tool is activated, the b key will work within this tool and
// override editor and application-wide contexts.
hotkey -keyShortcut "b" -name "ModifyBrushSizeNameCommand";
I replaced "paintEffects" with "MyPlugin" and tested the hotkeys in Maya.
The hotkey has been registered and is visible in the hotkey editor (as a custom script)
However when using my plugin / brushes, the global hotkey is executed not my custom command.
Could somebody explain how hotkeyCtx is supposed to work ? And how can I achieve making custom hotkeys for my plugin only ?
Thanks in advance