hotkey and hotkeyCtx

41 views
Skip to first unread message

Leto Atreides

unread,
Oct 8, 2024, 9:44:24 PMOct 8
to Python Programming for Autodesk Maya
Since last I've been going down the rabbit hole working with the hotkey and hotkeyctx commands and my experiences have again brought up a few questions.
Overall it works great, but in some cases it's a bit buggy(?)
This is rather long so I apologize on before hand.

Running this code returns the context clients for the Editors.
mc.hotkeyCtx(q=1, t="Editor", ca=1)

There's a few missing and I can't add the renderViewWindow
mc.hotkeyCtx( t="Editor", ac="renderViewWindow")

I'm guessing The UI itself needs support for this. Ive tried digging aound in the UI code for the UV Editor to see if there was something in there I could learn from.
C:\Program Files\Autodesk\Maya2024\scripts\others\texturePanel.mel

But I don't really know how all this works. The UI:s are made in Qt, but they create MEL files out of it. So the source is hidden, butt all the feature of Qt should still be there?

Then there's the Arnold Render View. For the window itself, the hotkeys doesn't show up in the Hotkey Editor. I'm guessing they are just hardcoded to the context of the UI. Been poking around in those files too and searched for keywords pertaining to "hotkey", "context", "shortcut", "keysequence" to see if any would show up. Alas, no luck.

I’ve been testing my hotkey setup in the UV Editor and noticed some unexpected behavior. When I press a hotkey in the UV Editor, it correctly prints "polyTexturePlacementPanel," which is the internal name for the UV Editor. When I then move the mouse pointer to the Graph Editor, it prints "graphEditor" as expected. I have configured my hotkey to print the current context for testing purposes.

However, I encountered an issue: when I hover over the title bar (where the window name and minimize, maximize, and close buttons are located) while still in the Graph Editor, it prints "polyTexturePlacementPanel" instead of "graphEditor."

I believe I’ve identified the source of this problem. If I restart Maya and open the Graph Editor first, it consistently prints "graphEditor" no matter where I hover in the window. However, if I then open the UV Editor, the hotkey works as it did before, but now it prints "graphEditor" when I hover over the Toolkit area.

Closing and reopening the Toolkit tab seems to resolve the issue  but the Graph Editor now has that printout "polyTexturePlacementPanel" in its title bar. I’m unsure how to fix this persistent context issue. Here’s the context code I’ve been using:


mc.runTimeCommand('uvtest', category= "Custom Scripts", commandLanguage = "python", command=("print(mc.hotkeyCtx(q=1, t=\"Editor\", cc=1))"), hotkeyCtx="polyTexturePlacementPanel", default=0)
mc.nameCommand("uvtestNameCommand", annotation='uvtestNameCommand', command='uvtest')
mc.hotkey(name="uvtestNameCommand", k="Left")

mc.runTimeCommand('getest', category= "Custom Scripts", commandLanguage = "python", command=("print(mc.hotkeyCtx(q=1, t=\"Editor\", cc=1))"), hotkeyCtx="graphEditor", default=0)
mc.nameCommand("getestNameCommand", annotation='getestNameCommand', command='getest')
mc.hotkey(name="getestNameCommand", k="Left")

If you made it all the way through, thank you. :-)
Reply all
Reply to author
Forward
0 new messages