hehe.. my reply was more for amitkhanna than for you. I just read what youwanted to do:
But your definition isn't final: I try to sketch the situation:
You got a scripted window with a button in it, right?
Now you select a sphere and the button shall turn blue just as you selected it?
Or is there something else you do to do the check? Of course you can make another button and a procedure that checks if there is a special object in your selection: e.g.:
CODE
global proc checkMySelection ()
{
//ls :very usefull list-command// -sl is for selection// "[]" because ls returns an array
string $sel[] = ls -sl
;
string $itemToCheck = "pSphere1";
int $itemIsInSel; //if you set an int its 0 by default
for ($item in $sel)
{
if ($item == $itemToCheck)
$itemIsInSel = 1;
}
if ($itemIsInSel)
print "Item IS in your selection!\n"; // or turn your button color
else
print "Item is NOT in your selection!\n"; // or turn your button color
}
But if you want it like described first: To change the color of the button as you pick it your object of desire thats an event that has nothing to do with you window at all. You have to create the window with a scriptJob parented to it, so this job acts if the window is open and is killed if you close the window.
Its really not a big deal. You gonna dig it!!
CODE
{
if (window -ex myWindow
) deleteUI myWindow;
window myWindow;
columnLayout;
button -bgc 1 1 1 myButton;
scriptJob
-parent myWindow
-event SelectionChanged "checkMySelection";
showWindow myWindow;
}
global proc checkMySelection ()
{
//ls :very usefull list-command// -sl is for selection// "[]" because ls returns an array
string $sel[] = ls -sl
;
string $itemToCheck = "pSphere1";
int $itemIsInSel; //if you set an int its 0 by default
for ($item in $sel)
{
if ($item == $itemToCheck)
{
$itemIsInSel = 1;
}
}
if ($itemIsInSel)
{ // sometimes the buttons are not updated ot once so make it invisible first
// and visible again
button -e -vis 0 -bgc 0 0 1 myButton;
button -e -vis 1 myButton;
}
else
{
button -e -vis 0 -bgc 0 1 0 myButton;
button -e -vis 1 myButton;
}
}