Drag and drop callback

There have been several posts in the past few months asking how drag and drop callbacks work. But there have been no replies. Does no one know how they work?

This would be especially useful when you have your own shelf tab layouts with buttons that you can drag to the trash icon. Then a command could be executed because of it.

Anyone interested in discussing this?

try echoing all and then se what maya calls when you use the default ones then root the default UI melscripts for the answer its there (since most of the ui is just script), then just figure out, cut, paste and modify.

But if someone knows the answer then you could ge graciouse enough to tell.

Thanks for the answer. If you try echoing all commands - you only get the "deleteUI" command. That's really not much help in this case.

Yeah byt swith the shelf off and then on and youll se what command builds the shelf (hopefully), then start rooting around that script (you can use help and whatIs to guide you!)

You are kind of missing the point. It is simple to build a shelf and have it work. That's not the problem. I would like to understand the -dgc and -dpc flags. That way when you drag a button to the trash, not only does it get rid of the button but it starts a command.

you write dragCallbacks for widgets you drag and you write dropCallbacks for the destination widgets.

just use the templates for these procs and write print statements for all the parameters and test it on a couple buttons. Write the dragCallback for button1 and the dropCallback for button2 and then drag button1 onto button2 and look at your script editor....it will all make sense.

Quite simple!

here is an example:

Item to drag:

window;
formLayout form;
text -al right
-l ("Test")
-dgc "dragText";
showWindow;


Item to drop:

window;
formLayout form;
text -al right
-l ("Test")
-dpc "dropText";

showWindow;


Drag&Drop Procedures:

global proc string[] dragText( string $dragged, int $x, int $y, int $mods )
{
string $result[1];
$result[0] = "text";
return $result;
}

global proc dropText ( string $dragged, string $drop, string $msgs[], int $x, int $y, int $type )
{
print("$dragged: " + $dragged + " $dropped: " + $drop + "n");

if( $dragged == $drop ) return;
if( size($msgs) < 1 ) return;
if( "text" != $msgs[0] ) return;

print("Drag&Drob successfull !!!n");

}


Hope that helps...

But I have another question!!!

I found out that not all MEL objects in Maya are drag&dropable. For instance I can drag text but I can't drag tabs athough the -dpc and the -dgc flag are available for almost all objects, layout, etc...

Does anyone have any experience with that problem?

Cheers
HumHum

It would've been cool if the provided example had worked - with Maya 2013 it doesn't...