shortcuteditor-nuke
shortcuteditor-nuke copied to clipboard
Context support
Hi there. Is there any plans to update with shortcutContext support for Nuke 8+ ?
Good point, this would be useful to add - although annoyingly it doesn't seem like the necessary API exists to do this:
https://docs.thefoundry.co.uk/nuke/105/pythonreference/nuke.MenuItem-class.html
The MenuItem
has the setShortcut
method relied on the by shortcut-editor currently, but no setContext
or similar
Requested this API from Foundry - "ID 158638 - setShortcut() should have functionality to set shortcut Context"
It looks like the context can be identified and modified via the command's Qt action:
from PySide2 import QtCore
x = nuke.menu('Nodes').addCommand('Test/Test X', 'print("x")', 'X', shortcutContext=0)
y = nuke.menu('Nodes').addCommand('Test/Test Y', 'print("y")', 'Y', shortcutContext=1)
z = nuke.menu('Nodes').addCommand('Test/Test Z', 'print("z")', 'Z', shortcutContext=2)
print(x.action().shortcutContext())
print(y.action().shortcutContext())
print(z.action().shortcutContext())
x.action().setShortcutContext(QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
z.action().setShortcutContext(QtCore.Qt.ShortcutContext.ApplicationShortcut)
y.action().setShortcutContext(QtCore.Qt.ShortcutContext.WindowShortcut)