Notifications
Clear all

[Closed] Updating UI items in other Rollouts

Hi all,
First post here and I’m a bit of a newbie with Maxscript but I’ve run into something I just haven’t been able to solve or find much info on. :banghead:

This is a way dumbed down version of my script but it illustrates the problem trying to have a B1 in Rollout 2 update a UI item state in Rollout 1. Any help would be greatly appreciated.

(
local isVar1 = false
local isVar2 = false

on execute do
(		
	floaterRA = newRolloutFloater "Test Floater" 220 300
		
	rollout rollout1 "Rollout1" 
	(
		checkbox cb1 "CHECKBOX1" checked:isVar1
		on cb1 changed state do isVar1=state
	)
					
	rollout rollout2 "Rollout2" 
	(
		checkbox cb2 "CHECKBOX2" checked:isVar2
		button b1 "ALL ON"
		on cb2 changed state do isVar2 = state
		on b1 pressed do
		(
			Var1 = true; Var2=true
			cb1.state = Var1 --<<<<<<<<<<<<<<<<<<<<<<<<<
			cb2.state = Var2
		)
	)
	addRollout rollout1 floaterRA 
	addRollout rollout2 floaterRA 
)

)

2 Replies

Controls are children of their rollout. To access controls on another rollout, just precede their name with the name of the rollout. In your example:


rollout1.cb1.state = var1

The code will fail if the external rollout is not initialized, so it’s best to add a check for that.

Thank you so much for the response. I had tried that unsuccessfully before posting but have since figured it out. The rollout variables need to defined as local so a

local rollout1
local rollout2

at the top + the rollout1.cb1.state = var1 did the trick.

Thank you.