View Full Version : drag and drop proc
ph2003 03-11-2008, 09:17 AM hi there,
im still new into mel scipting...
im trying to do a MMB drag and drop cmd.
i found some code in this forum but it wont let me execute it in maya
is there any error with this code?
code:
global proc string[] fooDrag(string $dragControl, int $x, int $y, int $mods)
{
string $ff[] = ("You droped me!");
return $ff;
}
global proc fooDrop(string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type)
{
warning $msgs[0];
}
if (`window -ex foo`)
deleteUI foo;
window foo;
columnLayout -adj 3;
button -l "EEE" -dgc "fooDrag" -dpc "fooDrop" foo_Button1;
showWindow foo;
and got this error:
// Error: string $ff[] = ("You droped me!");
//
// Error: Cannot cast data of type string to string[]. //
ive checked the maya docs...
global proc string[] callbackName(string $dragControl, int $x, int $y, int $mods)
global proc callbackName(string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type)
any help would be aprecieted.
thx!
|
|
strarup
03-11-2008, 09:35 AM
Hi,
well I'm not at a pc with Maya at the moment...
but change your message ("You droped me!") into an array instead of just a string... using {} instead of ()...
global proc string[] fooDrag(string $dragControl, int $x, int $y, int $mods)
{
string $ff[] = {"You droped me!"};
return $ff;
}
hope that helps.. :)
kind regards
Strarup
ph2003
03-11-2008, 02:56 PM
hi there Strarup,
yay thx! it works fine now!
sry i always mess up with {} instead of ()....
well i got some update code for now,
that im trying to MMB drag some selected text in scirpt editor or MMB drag a mel from shelves into this textscrollList in my window.
but with this code it wont alow me to put any into the list....
code:
global proc string[] phDrag(string $dragControl, int $x, int $y, int $mods)
{
string $ff[] = `textScrollList -q -a fooLayout`;
return $ff;
}
global proc phDrop(string $dragControl, string $dropControl, string $ff[], int $x, int $y, int $type)
{
string $parts[];
tokenize $dropControl "|" $parts;
int $drop;
for ( $i = 0; $i < size($ff); $i++) {
if ($parts[size($parts)-1] ==$ff[$i])
$drop = $i+1;
}
textScrollList -e -a $dragControl $drop fooLayout;
}
global proc foo()
{
if (`window -ex foo`)
deleteUI foo;
window foo;
gridLayout -nc 1 -cw 120;
textScrollList -dgc "phDrag" -dpc "phDrop" fooLayout;
showWindow foo;
}
foo;
is there posible to do the drag/drop action like u put some selected mell cmd in script editor into a custom textfield list?
or it just too hard to do it for a beginer?:sad:
thx in advance!
strarup
03-12-2008, 09:29 PM
sry i always mess up with {} instead of ()....
hehe np... :)
I haven't been playing very much with the drag functions...
but will try and have a look at it... however think you need an update/rebuild textscroll function...
and the following is a guess since I'm not that well known with the drag functions...
however it seems that in your phDrag at your definition of $ff[] = `textScrollList -q -a fooLayout`;
you are calling the textScrollList... which is emthy... and therefore dragging an emtphy string array...
but that is just a guess... since I'm not sure about how the drag function works... :)
is there posible to do the drag/drop action like u put some selected mell cmd in script editor into a custom textfield list?
I think it is posible... just don't know how at the moment... :)
kind regards
Strarup
ph2003
03-13-2008, 07:32 AM
hi there,
oh i just found theres another cmd that called shelfTabLayout...
i think this is the best way to go... just make another shelflayout instead of a textfield
(its just works same like the shelf that i wanted)
and ive found a few scripts that in highend3d with this function...:scream:
and it works perfect for me atm...
so guess im wasting my time for trying to write another new one :sad:
thx for the kindly help though:thumbsup:
CGTalk Moderation
03-13-2008, 07:32 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.