PDA

View Full Version : how to change a rollout in real time


f3derico
09-05-2007, 11:44 AM
I've this rollout
test = newrolloutfloater "test" 250 200


rollout params "bones"
(
radiobuttons radbtn labels:#( "1","2") default:1 pos:[80,25]

button 1 "1"


)

addrollout params test

now when i change the radiobutton selection it's possible to change for example the button "1" in something else ?

JHN
09-05-2007, 01:06 PM
Do you want to change the button to a new type of control?
You can't do it dynamicly, if you would want that you'll have to build the rollout as string and execute it... pretty tedious work...

You could hide the button as well and display a predefined button in the same location... "semi dynamicly"...

Be sure to check the manual on Rollout and control common properties, also pull apart scripts that do what you want to check how others are doing it!

Hope this gets you started.
-Johan

MoonDoggie
09-05-2007, 03:00 PM
test = newrolloutfloater "test" 250 200

rollout params "bones"
(
radiobuttons radbtn labels:#( "1","2") default:1 pos:[80,25]
button btn_one "1"
button btn_two "2"

on btn_one pressed do (
radbtn.state = 1
)

on btn_two pressed do (
radbtn.state = 2
)
)
addrollout params test



1. Don't name your button 1, that will be interpreted by the interpreter as the value: 1. Name your buttons btn_somethingdescriptive

Is that something like what you want to do?

f3derico
09-05-2007, 03:37 PM
thanks moondoggie but this code change the radiobutton by pressin one of the button. i need the inverse thing. I need a menu appear if radiobutton1 is selected and another different menu if radiobutton 2 is selected.

JHN
09-05-2007, 03:48 PM
If it's complete menu's you want to switch, you should make a rollout per menu set. And show hide those with your radio button.

-Johan

MoonDoggie
09-05-2007, 07:44 PM
test = newrolloutfloater "test" 250 110

rollout params "bones"
(
radiobuttons radbtn labels:#( "1","2") default:1 pos:[80,25]
button btn_one "1"
button btn_two "2" visible:false offset:[0,-26]

on radbtn changed state do (
if state == 1 then (
btn_one.visible = true
btn_two.visible = false
)
else if state == 2 then (
btn_one.visible = false
btn_two.visible = true
)
)
)
addrollout params test





UI elements often have a visible property, is this closer to what you're looking for?

f3derico
09-06-2007, 08:42 AM
thanks moondoggie it's a good example I'll keep in mind.
tonight I've tried to use subrollout and this is the result :


myrollout = newrolloutfloater "my rollout" 250 300

rollout radio "radio" height:400
(
radiobuttons rd "" labels:#("first","second")

subrollout test "test"

on rd changed state do



if rd.state == 2 then


(AddsubRollout radio.test BB
removesubrollout radio.test AA
)

else

(AddsubRollout radio.test AA
removesubrollout radio.test BB
)

)


rollout AA "first menu" height:150
(
spinner spA "spinner 1"
)

rollout BB "second menu" height:150
(
button btn1 "button 2"
checkbox ckb1 "checkbox 2" align:#center
)

addrollout radio myrollout

AddsubRollout radio.test AA


radio.height += 150
radio.test.height += 80

mir-vadim
09-06-2007, 09:08 AM
Hi, there is one mistake in Your code.
If You want to make some operation with rollout in another rollout, You must declare first rollout as global, otherwise MaxScript will give You an error at first launch. It will work fine at second lauch, but first launch will give You an error.

Global AA
Global BB

f3derico
09-06-2007, 09:24 AM
Hi, there is one mistake in Your code.
If You want to make some operation with rollout in another rollout, You must declare first rollout as global, otherwise MaxScript will give You an error at first launch. It will work fine at second lauch, but first launch will give You an error.

Global AA
Global BB

yes I've noticed, thanks

CGTalk Moderation
09-06-2007, 09:24 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.