[some code above labeled that dock be reinitialized if it's already there with some strings]
$CB = `window-t "Channel Box / Tool"[a bunch of buttons under it]
-tlb true -wh 260 1000`;
columnLayout -adj true;
rowColumnLayout -nc 1;
button -e -l "<-" -w 260 -h 32 -c "ToggleMergeToolbar";
columnLayout -adj true;
// create a channel box widget
channelBox -h 600;
setParent..;
setParent..;
showWindow $CB;
global proc ToggleMergeToolbar(){
global string $TestIt;
global string $MergeWndDisplay;
$TestIt = `paneLayout -q -vis MergeWindow`;
if ($TestIt == 0){$MergeWndDisplay = "on";}
paneLayout -e -vis 1 MergeWindow;
button -e -l "->" -c "ToggleMergeToolBar;";
if ($TestIt == 1){$MergeWndDisplay = "off";if (`dockControl -ex CB`){
paneLayout -e -vis 0 MergeWindow;dockControl -e -w 400 CB;}
}
button -e -l "<-" -c "ToggleMergeToolbar;";
}
[MergeWindow]
Replies
global proc ToggleMergeToolbar() { global string $TestIt; global string $MergeWndDisplay; $TestIt = `paneLayout -q -vis MergeWindow`; if ($TestIt == 0) { $MergeWndDisplay = "on"; paneLayout -e -vis 1 MergeWindow; button -e -l "->" -c "ToggleMergeToolBar;"; } else if ($TestIt == 1) { $MergeWndDisplay = "off"; paneLayout -e -vis 0 MergeWindow; button -e -l "<-" -c "ToggleMergeToolbar;"; if (`dockControl -ex CB`) { dockControl -e -w 400 CB; } } } [MergeWindow]You've got
dangling out there by itself when it looks like it should be run if $TestIt == 1 since button -e -l "->" -c "ToggleMergeToolBar;"; is run if $TestIt == 0
Good luck, hope that helps
Currently, I have my script working EXCEPT that it cannot find an object in my script. Apparently, it's looking for the object "MergeWindow" which is a procedure I have stated before it. So I'm not really understanding what I'm missing...
Thank you for the idea though! I might try to mess around with it if I get it working and my replaced button doesn't show.
-Criso
(also: it might be pedantic, and more typing, but personally I'd type out the full names of parameters like -edit rather than -e, -command rather than -c. It makes the code a lot easier to understand IMHO.)
NOTE:
Red code means how the code was originally.
Green code means what the code should be changed to.
(I hope you're not colorblind... If so sorry in advance.)
global proc ToggleMergeToolbar() { // $TestIt is being compared to integer values below rather than strings // so it seems better to declare it as a int type. Also it probably shouldn't // be a global unless you are using it outside of ToggleMergeToolbar(), // possibly the same for $MergeWndDisplay... [COLOR="Red"]global string $TestIt;[/COLOR] [COLOR="Lime"]int $TestIt;[/COLOR] [COLOR="Red"]global string $MergeWndDisplay;[/COLOR] [COLOR="Lime"]string $MergeWndDisplay;[/COLOR] // If MergeWindow is a variable declared somewhere I think it needs a "$" // in front of it. [COLOR="Red"]$TestIt = `paneLayout -query -visible MergeWindow`;[/COLOR] [COLOR="Lime"]$TestIt = `paneLayout -query -visible $MergeWindow`;[/COLOR] if ($TestIt == 0) { $MergeWndDisplay = "on"; // Possibly the same missing "$" deal as above... [COLOR="Red"]paneLayout -edit -visible 1 MergeWindow;[/COLOR] [COLOR="Lime"]paneLayout -edit -visible 1 $MergeWindow;[/COLOR] button -edit -label "->" -command "ToggleMergeToolBar;"; } else if ($TestIt == 1) { $MergeWndDisplay = "off"; // Possibly the same missing "$" deal as above... [COLOR="Red"]paneLayout -edit -visible 0 MergeWindow;[/COLOR] [COLOR="Lime"]paneLayout -edit -visible 0 $MergeWindow;[/COLOR] // I still think you should put this here or else it'll always execute [COLOR="Lime"]button -edit -label "<-" -command "ToggleMergeToolbar;";[/COLOR] if (`dockControl -exists CB`) { dockControl -edit -width 400 CB; } } // If you leave this here like so it'll always change your button's // label to "<-" even if ($TestIt == 0) is true. [COLOR="Red"]button -edit -label "<-" -command "ToggleMergeToolbar;";[/COLOR] } // Is this where the declaration of MergeWindow is in your .mel file? // If so you might want to place it above the ToggleMergeToolbar() procedure. // // The reason being: if Maya interprets MEL line by line from top to bottom // then it might not understand what "MergeWindow" is when it first encounters // it within the ToggleMergeToolbar() procedure above. // // I don't know if that's really how Maya interprets MEL, but some other // programming languages are picky about such things. [MergeWindow]If none of that helps post up all of your code. It'll be easier to see what's going on that way.
http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/mel/index.html
http://ewertb.soundlinker.com/mel/mel.095.php
You cannot edit a button when you are creating it.
I had done a revamp of everything that I had listed (I realized I posted some incorrect code and proceeded to check things and fix them). Still having an issue, but I'll get to that in a moment. At the time I posted this, I was stressed out beyond all reason so I'm sorry that some of the code seems flaky, I was just not thinking straight at this point in time. That aside...
I would like to keep some of the code confidential, so instead of posting it up, I'll PM it to you guys. It's nothing special, I just would like to keep some of it somewhat private.
Ben,thank you for the suggestions. I'll try to implement them with the original code and see if it works. I used global strings because I have a couple strings that needed to be repeated a few times within the code. So, it was outside of just that toolbar. I've only been coding for about a month, mel script being the first thing I learned and python being the second. I've previously studied a bit of both of those websites, very helpful. I'm not sure how I'm doing after a month of programming...
Haiddasalami Yeah, I realized afterwards that I was being a bit stupid on that portion. I'll PM you.
That would be fun if I was. ;D