HyperShade dragger context question. TextField under pointer querry possible?!

44 views
Skip to first unread message

Raul Teleki

unread,
Jan 9, 2014, 12:59:48 PM1/9/14
to python_in...@googlegroups.com
 Hey guys!
 Maybe one of you knows this. When you are dragging a shader from maya's Hypershade, how can u querry that context or how is that information stored and then pasted when you finish the drag?
 I need this because I have some textFields that have a drop command on them, but the drop command will only then allow me to drop my own specific strings in there and will block out anything else. You could do an if command based on a selection, so if i select the shader then i'd edit that textfield based on the selection, but the thing is woulnd't like to select the shader as that clears the current selection.

 Thanks a lot.
 Another way around this would be to querry the textField under pointer, but i dont think that's possible, or?!


Ævar Guðmundsson

unread,
Jan 9, 2014, 9:05:51 PM1/9/14
to python_in...@googlegroups.com
I'm no expert on the matter but I'd guess there is a dragEnter event and presumably, as long as your drag content is plain text you should be able to query the mimetext from that event as it's open...

Hope that helps, if there are no other suggestions I'll try throwing up a practical case tomorrow, if you don't mind me asking though, since it's a really interesting problem you have, what would you do with the text once you have it queried while it's floating? Display it somewhere if just making sure it's copied to a separate clipboard?

Kurian O.S

unread,
Jan 9, 2014, 9:13:35 PM1/9/14
to python_in...@googlegroups.com
-Another way around this would be to querry the textField under pointer, but i dont think that's possible, or?!-

If yopu are using pyqt then Natan got some ideas http://nathanhorne.com/?p=298

import sip
import maya.cmds as cmds
import maya.OpenMayaUI as apiUI
from PyQt4 import QtGui, QtCore

def getMayaWindow():
'Get the maya main window as a QMainWindow instance'
ptr = apiUI.MQtUtil.mainWindow()
return sip.wrapinstance(long(ptr), QtCore.QObject)
def getFocusWidget():
'Get the currently focused widget'
return QtGui.qApp.focusWidget()

def getWidgetAtMouse():
'Get the widget under the mouse'
currentPos = QtGui.QCursor().pos()
widget = QtGui.qApp.widgetAt(currentPos)
return widget


On Thu, Jan 9, 2014 at 6:05 PM, Ævar Guðmundsson <aevar.gu...@gmail.com> wrote:
I'm no expert on the matter but I'd guess there is a dragEnter event and presumably, as long as your drag content is plain text you should be able to query the mimetext from that event as it's open...

  Hope that helps, if there are no other suggestions I'll try throwing up a practical case tomorrow, if you don't mind me asking though, since it's a really interesting problem you have, what would you do with the text once you have it queried while it's floating? Display it somewhere if just making sure it's copied to a separate clipboard?

--
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/adbee889-b1c1-4be9-8e5a-c72cd31171d1%40googlegroups.com.



--
--:: Kurian ::--

Ravi Jagannadhan

unread,
Jan 9, 2014, 9:58:07 PM1/9/14
to python_in...@googlegroups.com
Magic!



For more options, visit https://groups.google.com/groups/opt_out.



--
Where we have strong emotions, we're liable to fool ourselves - Carl Sagan

Raul Teleki

unread,
Jan 12, 2014, 2:35:05 PM1/12/14
to python_in...@googlegroups.com
 Hey guys. I'm using this stuff for a shader per shell assignment script. i got it all to work and do what its supposed to do, but for ease of use, next to my shader assign slots there is a textScrollList with all the shaders in my scene so i can drag and drop shaders easily into my assignment slots.
 I'm looking for a simple maya solution for this as i am changing workplace/OS quite often and i can't depend of third party plugins
shellShaderAssign.JPG
Reply all
Reply to author
Forward
0 new messages