PDA

View Full Version : clicking UI checkboxes


Doogie
12-02-2003, 05:47 AM
I'm trying to add a button to my UI window that ticks/unticks multiple checkboxes elsewhere in the window. When I tried this, it will check the box but it doesn't execute the code associated with the checkbox.

Right now, I could check each box, then retype what each checkbox does (for both on and off) to get this to work... but I'm assuming there is an easier way I just havent found.

Any suggestions?

dwalden74
12-02-2003, 07:41 AM
Yea, this often doesnīt work with UI elements- in order for the controlīs command to be executed, in most cases you have to physically set the state of the control, and not via other MEL. So Iīd say just add the command to your button command, or put it into another proc which the button can call.

brubin
12-02-2003, 01:57 PM
Originally posted by Doogie
I'm trying to add a button to my UI window that ticks/unticks multiple checkboxes elsewhere in the window. When I tried this, it will check the box but it doesn't execute the code associated with the checkbox.

Right now, I could check each box, then retype what each checkbox does (for both on and off) to get this to work... but I'm assuming there is an easier way I just havent found.

Any suggestions?

well, can you post the code so one can see?
unless you want someone to talk right out of their arse, of course...

s.

Doogie
12-02-2003, 03:39 PM
sure, examples are fun

window;
columnLayout;
checkBox -l head -onc "print Head " -ofc "print \"No Head\" " head;
checkBox -l shoulders -onc "print Shoulders " -ofc "print \"No Shoulders\" " shoulders;
checkBox -l knees -onc "print Knees " -ofc "print \"No Knees\" " knees;
checkBox -l toes -onc "print Toes " -ofc "print \"No Toes\" " toes;

separator -height 10 -width 50 -style "in";

checkBox -l everything
-onc "checkBox -e -v 1 head;checkBox -e -v 1 shoulders;checkBox -e -v 1 knees;checkBox -e -v 1 toes;"
-ofc "checkBox -e -v 0 head;checkBox -e -v 0 shoulders;checkBox -e -v 0 knees;checkBox -e -v 0 toes;"
everything;
showWindow;


See how when you click on the "everything" button, it will check everything, but not run the code. Im actually using iconTextCheckBox, but I'm pretty sure they all work the same.

Origionally, was going to do what dwalden74 suggested, but my code is bulky enough (also if I end up changing or adding checkBoxes).

dwalden74
12-02-2003, 04:51 PM
[QUOTE]Origionally, was going to do what dwalden74 suggested, but my code is bulky enough...QUOTE]

Some of my own checkboxes and buttons have commands that span 10-20 lines of code...

-David

brubin
12-09-2003, 09:35 PM
ok, sorry for asking-for-code and then not replying, was busy though...

below are my thoughts on this,
it looks like a lot more code, but it allows you *comfortably to do what you wanted to do.

HIH
s.

if (`window -ex win1`) deleteUI win1 ;
window win1;
columnLayout CL1;
checkBox -l head -onc "toggleCheckies \"ON\" 1" -ofc "toggleCheckies \"OFF\" 1" head;
checkBox -l shoulders -onc "toggleCheckies \"ON\" 2" -ofc "toggleCheckies \"OFF\" 2" shoulders;
checkBox -l knees -onc "toggleCheckies \"ON\" 3" -ofc "toggleCheckies \"OFF\" 3" knees;
checkBox -l toes -onc "toggleCheckies \"ON\" 4" -ofc "toggleCheckies \"OFF\" 4" toes;

separator -height 10 -width 50 -style "in";

checkBox -l everything -onc "toggleCheckies \"ON\" 0" -ofc "toggleCheckies \"OFF\" 0" everything;
showWindow win1;

global proc toggleCheckies(string $state , int $which)
{
switch ($which)
{
case 0:
// toggle all
if ($state == "ON")
{
checkBox -e -v 1 head;
checkBox -e -v 1 shoulders;
checkBox -e -v 1 knees;
checkBox -e -v 1 toes;
print (">0:\tHead\n\tShoulders\n\tKnees\n\tToes\n") ;
}
if ($state == "OFF")
{
checkBox -e -v 0 head;
checkBox -e -v 0 shoulders;
checkBox -e -v 0 knees;
checkBox -e -v 0 toes;
print ("<0:\tNo Head\n\tNo Shoulders\n\tNo Knees\n\tNo Toes\n") ;
}
break;

case 1:
// toggle head
if ($state == "ON")
{
print (">1:\tHead\n") ;
}
if ($state == "OFF")
{
// first make sure, that the evrything-check is off
if (`checkBox -q -v everything` == 1) checkBox -e -v 0 everything ;
print ("<1:\tNo Head\n") ;
}
break ;

case 2:
// toggle shoulder
if ($state == "ON")
{
print (">2:\tShoulders\n") ;
}
if ($state == "OFF")
{
// first make sure, that the evrything-check is off
if (`checkBox -q -v everything` == 1) checkBox -e -v 0 everything ;
print ("<2:\tNo Shoulders\n") ;
}
break ;

case 3:
// toggle knees
if ($state == "ON")
{
print (">3:\tKnees\n") ;
}
if ($state == "OFF")
{
// first make sure, that the evrything-check is off
if (`checkBox -q -v everything` == 1) checkBox -e -v 0 everything ;
print ("<3:\tNo Knees\n") ;
}
break;

case 4:
// toggle toes
if ($state == "ON")
{
print (">4:\tToes\n") ;
}
if ($state == "OFF")
{
// first make sure, that the evrything-check is off
if (`checkBox -q -v everything` == 1) checkBox -e -v 0 everything ;
print ("<4:\tNo Toes\n") ;
}
break;

default:
error "You're using this function wrong!" ;
break;
}

}

CGTalk Moderation
01-16-2006, 07:00 PM
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.