[Closed] Access User Interface Controls from another rollout
Hi there,
Just wondering, how could I access the User Interface Controls from another rollout?
In this super quick example I just want whatever is typed in rollout one to end up in the label in rollout two.
Can someone point me in the right direction?
(
rollout first_rollout "1st Rollout" category:1
(
edittext testText "" text:"" width:160 height:16 align: #center
on testText changed newtext do (
second.text = newtext
)
)
rollout second_rollout "2nd Rollout" category:2
(
label second "Second"
)
rf = newRolloutFloater "Rollout Order Test" 200 140
addRollout first_rollout rf
addRollout second_rollout rf
)
Thanks!
Pete
well – that was not too far off.
First thing would be referencing the label text with its full name by adding the rollout name
on testText changed newtext do (
second_rollout.second.text = newtext
)
But because Maxscript is constructed the way it is , this will throw an unknown property … in undefined exception. This is because at the time maxscripts creates the on testText changed newtext do handler, it indeed does’nt know about second_rollout because it is’nt defined yet. A trick to get arround this is to use a thing i would call “pseudo forward declaration”
Simply declare a variable with the corresponding name beforehand. So essentially at it’s creation, on testText changed knows about a variable named second_rollout ( even if that one is still undefined at that point )
But later on, when Maxscript reaches the second_rollout definition, it will assign the rollout to the variable. Now when the on testText changed handler is triggered, everything is set up and the label text in the second rollout can be referenced and set correctly
The final code would look like this
(
-- forward declaration
second_rollout
rollout first_rollout "1st Rollout" category:1
(
edittext testText "" text:"" width:160 height:16 align: #center
on testText changed newtext do (
second_rollout.second.text = newtext
)
)
rollout second_rollout "2nd Rollout" category:2
(
label second "Second"
)
rf = newRolloutFloater "Rollout Order Test" 200 140
addRollout first_rollout rf
addRollout second_rollout rf
)