Notifications
Clear all

[Closed] how to change a rollout in real time

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 ?

8 Replies
 JHN

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


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?

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

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


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?

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
  

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

1 Reply
(@f3derico)
Joined: 11 months ago

Posts: 0

yes I’ve noticed, thanks