2 To use, make sure that externalDropCallback.py is in your MAYA_PLUG_IN_PATH
6 maya.cmds.loadPlugin("externalDropCallback.py")
8 Drag and drop events should appear in the script editor output.
12 import maya.OpenMaya
as OpenMaya
13 import maya.OpenMayaUI
as OpenMayaUI
17 class PyExternalDropCallback(OpenMayaUI.MExternalDropCallback):
21 OpenMayaUI.MExternalDropCallback.__init__(self)
23 def externalDropCallback( self, doDrop, controlName, data ):
24 str = (
"External Drop: doDrop = %d, controlName = %s" % (doDrop, controlName))
27 if data.mouseButtons() & OpenMayaUI.MExternalDropData.kLeftButton:
29 if data.mouseButtons() & OpenMayaUI.MExternalDropData.kMidButton:
31 if data.mouseButtons() & OpenMayaUI.MExternalDropData.kRightButton:
35 if data.keyboardModifiers() & OpenMayaUI.MExternalDropData.kShiftModifier:
37 if data.keyboardModifiers() & OpenMayaUI.MExternalDropData.kControlModifier:
39 if data.keyboardModifiers() & OpenMayaUI.MExternalDropData.kAltModifier:
44 str += (
", text = %s" % data.text())
47 for (i,url)
in enumerate(urls):
48 str += (
", url[%d] = %s" % (i, url))
51 str += (
", html = %s" % data.html())
54 str += (
", color = (%d, %d, %d, %d)" % (color.r, color.g, color.b, color.a))
56 str += (
", image = true")
58 sys.stdout.write( str )
59 return OpenMayaUI.MExternalDropCallback.kMayaDefault
65 def initializePlugin(plugin):
67 PyExternalDropCallback.instance = PyExternalDropCallback()
68 OpenMayaUI.MExternalDropCallback.addCallback( PyExternalDropCallback.instance )
69 sys.stdout.write(
"Successfully registered callback: PyExternalDropCallback\n")
71 sys.stderr.write(
"Failed to register callback: PyExternalDropCallback\n")
77 def uninitializePlugin(plugin):
79 OpenMayaUI.MExternalDropCallback.removeCallback( PyExternalDropCallback.instance )
80 sys.stdout.write(
"Successfully deregistered callback: PyExternalDropCallback\n")
82 sys.stderr.write(
"Failed to deregister callback: PyExternalDropCallback\n")