Hi,

I am trying to install an event filter on the main maya window to process a 
drop event. In the snippet below I can get the key press event, but the 
DragEnter and Drop event never gets called. Instead a function called 
"performFileDropAction" gets called.

How would I do this?

Thanks,
/ J

from PySide2 import QtGui, QtCore, QtWidgets
from maya import OpenMayaUI as omui
from shiboken2 import wrapInstance


class MyEventFilter(QtCore.QObject):
    
    def eventFilter(self, obj, event):
                     
        if event.type() is event.KeyPress:
            print("Ate key press", event.key())
            event.accept()
            return True
            
        elif event.type() is event.DragEnter:
            print('DragEnter')
            event.accept()
                 
        elif event.type() is event.Drop:
            print('Drop')
            event.accept()
        
        else:
            # standard event processing
            return QtCore.QObject.eventFilter(self, obj, event)
                               
main_win = wrapInstance(long(omui.MQtUtil.mainWindow()), QtWidgets.QWidget) 
my_filter = MyEventFilter()
main_win.installEventFilter(my_filter)
#main_win.removeEventFilter(my_filter)


-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/180b8d68-8f17-4dd2-a96e-068027de2e77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to