View Full Version : Quick question on RadioButtons
03-24-2009, 01:10 AM
Hi, I'd like to make a little interface in a custom attributes.
I have an object that as a Link Constraint. I'd like to list the objects available as target for the link constraint with RadioButtons.
So when you check on of the option, the target is set with a key.
My problem is that I'd like the Radio Button last checked to stay checked until I click a new one.
Right now, everything happens like I want to except that everytime I click on something else or change tabs, when I come back to my custom attribute holder the first Radio Button is now checked and not the last one that was selected.
Does somebody know if this is possible?
Thanks everyone for your time.
03-24-2009, 01:19 AM
you'll have to store the actively selected radio button index in a variable ( someVar = <radiobuttons>.state ), and then re-store that active selection (<radiobuttons>.state = someVar ) when the rollout (or tab if you use an actual tab control) re-displays.
03-24-2009, 01:35 AM
Thanks for the quick answer ZeBoxx2.
I'm wondering exactly how I would re-store the active selection. Who I put the code in the actual custom attribute or it's something that needs to happen outside of the custom attribute?
Thanks a lot for your help.
03-24-2009, 08:22 AM
You will need to store the variable in a parameter block. The good thing about this is you can create a link to the variable itself and the state integer of the radio buttons with the ui property of the parameter. When specified, it corresponds to the control with the same name and links the parameter with the control. You will need to specify the rollout in the parameter declaration, and the ui element in the variable itself, a little like this -
_RdoAttr = Attributes RDOStateAttr
parameters main rollout:RdostateRo
rdostate type:#integer default:1 ui:rdostate
rollout RdostateRo "RadioButton State" width:162 height:51
radioButtons rdostate "State" pos:[3,5] width:155 height:30 labels:#("1", "2", "3", "4", "5") columns:5
on rdostate open do
--- link code here
custAttributes.add (modPanel.getCurrentObject() ) _RdoAttr
if you need anymore information about types of variable that you can store in the parameter block, then take a look at the 'scripted plugin clauses' topic in the MXS help. cheers!
p.s because of the modPanel.getCurrentObject(), you would be best to apply an attribute holder modifier and run the code!
03-24-2009, 01:27 PM
Awesome thanks LoneRobot, it works! I'm still somewhat new to maxscript. That does exactly what i need.
03-24-2009, 01:27 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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.