I have been at this for an hour, with various variations but have not had any success with it.
Here is a very basic sample of one approach I tried:
def foo(dragControl, x, y, modifiers, *args):
print("--------------------------------- Hello World ------------------------------------")
cmds.channelBox('mainChannelBox',dragCallback=foo)
Am expecting, when I engage, the MMB on either the viewport (with an attribute selected on the channel box) or on top of the channel box, the message in foo to be printed.
But in this case nothing is printed on either case. The few AI models I usually consult with just take me around in circles.
I would appreciate any help on this matter, thank you.
This is not what the generic dragCallback flag is for. You will find that practically ALL UI controls have this flag, in conjunction with the dropCallback flag, and together they are used to support drag/dropping from one UI to another (e.g. dragging a button from one UI and dropping it onto another to trigger an action).
You are also limited to only dragging a control from a Maya cmds UI and dropping it onto a control from a cmds UI (in other words, you cannot use it to capture aribitrary dragging, or to drag an object from the viewport, or a shader from the Hypershade, or drag a button and drop it onto viewport, etc… (unless you dig directly into the guts of Qt/PySide2))
This has nothing to do with MMB-dragging attrs in the viewport, which sounds like what you ultimately want to do. For that I think you have to use the cmds.dragAttrContext command.
1 Like
I was really just trying to figure out what the flag was for, as it looked interesting just by its name and description.
Now that I know, it seems usefull for a lot of things, will have to look further into it soon, especially since its a common UI convention.
Cheers!
I wrote a very simple tutorial on it (about 15 years ago) which you can take a look at if you want.
Maya MEL Drag/Drop Tutorial
It’s using MEL, but the same rules and logic still apply for Python. I used Maya’s built-in drag/drop like this on quite a few old UIs until I switched completely to PySide2 some time ago.
1 Like
I read that article and it is what I needed to undersand the concept. I bookmarked it for the fututre. Cheers.