Hi. as there are a few things that bothers me with Maya's hotkeys system.
I'm curious if I can code up a class in PySide2 to create my own hotkeys system.I've read a few threads on here and I've experimented with the eventFilter before.However if I understand it correctly, using eventFilter installed on the Maya main window is bad as all events will go from C++ to python to C++, making Maya slower?
I'm not sure that I should use an eventFilter, but I want to be able to map both key press and key release that works wherever I have my focus in Maya.To have it context sensitive could also be nice so I can set up that the same key sequence calls a function when in the UV-editor and then another if I have focus in the viewport.What do you suggest here?
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b3f25ba2-8233-4dc2-9847-d429336f77d0n%40googlegroups.com.
@Justin Israel
Thank you. That gives me a lot to think about.
How does Maya's native hotkeys work. Are they in fact Qt based? And are they done with the eventFilter in C++?
For example looking at Ctrl + L it's mapped to a different command in three different editors.It seems all editors are context sensitive? If I add a new hotkey to a command under the UV editor, I need the UV editor to be in focus for this command to execute.
For my own custom commands, they are obviously not context sensitive as i can run them from any window that has focus. If I should have mapped Ctrl + L to a custom command, it will override any default context sensitive command defined in Maya.
--On Saturday, September 28, 2024 at 1:45:46 AM UTC+2 Justin Israel wrote:On Sat, Sep 28, 2024, 11:41 AM Leto Atreides <stru...@gmail.com> wrote:Hi. as there are a few things that bothers me with Maya's hotkeys system.
I'm curious if I can code up a class in PySide2 to create my own hotkeys system.I've read a few threads on here and I've experimented with the eventFilter before.However if I understand it correctly, using eventFilter installed on the Maya main window is bad as all events will go from C++ to python to C++, making Maya slower?Yea don't do that in python. If you are going to do it, write it in C++I'm not sure that I should use an eventFilter, but I want to be able to map both key press and key release that works wherever I have my focus in Maya.To have it context sensitive could also be nice so I can set up that the same key sequence calls a function when in the UV-editor and then another if I have focus in the viewport.What do you suggest here?You would have to catch the events before Maya widgets receive them. If you do it at the application with an event filter, it should be C++ and would have to check every object to see if it is one you want to handle.Otherwise you have to find each Qt widget reference and install an event filter, to make it more context specific.--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b3f25ba2-8233-4dc2-9847-d429336f77d0n%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/70f88322-5f2f-482a-9fa1-e24e892a3eecn%40googlegroups.com.
from PySide2 import QtWidgets, QtGui
from maya import OpenMayaUI as omui
import shiboken2
def the_b():
print("I did the B")
main_window_ptr = omui.MQtUtil.mainWindow()
window = shiboken2.wrapInstance(int(main_window_ptr), QtWidgets.QMainWindow)
# Enable
b = QtGui.QKeySequence("B")
shortcut = QtWidgets.QShortcut(b, window)
shortcut.activated.connect(the_b)
# Disable
shortcut.activated.disconnect(the_b)
shortcut.setEnabled(False)
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c04ce546-cf88-46b8-99f1-88b5304bcab1n%40googlegroups.com.
I feel that the QShortcut doesn't really add anything to the Maya's native hotkeys implementation(unless it does in fact handle combinations with the mouse buttons). You can't set it to be context sensitive and it can't be setup with a release command. Correct me if I'm wrong.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/076bd8ac-44d7-4e42-a9b5-6252fe9f31afn%40googlegroups.com.
Right, but you have to create it with the window and this is easy to set up and maintain for your custom ones, but not so much for Graph Editor, UV Editor etc, right? Or am I missing the point?
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/53bf5a8c-12ca-48e7-a59c-f3932d105368n%40googlegroups.com.