Notifications
Clear all

[Closed] Communication between rollouts in floater

OK, here’s a simple rollout with two spinners that link to each other…


rollout spns "Example 1: Rollout spinners"
(
	spinner spn_A "1st spinner"
	spinner spn_B "2nd spinner"
	local n
 
	on spn_A changed value do
	(
		n = spn_A.value
		spn_b.value = n
	)
	on spn_B changed value do
	(
		n = spn_B.value
		spn_A.value = n
	)
)
createDialog spns 200 50

As you can see, any change in one spinner updates the other.

Now here’s a floater with spinners in two rollouts…


(
local m
rollout r1 "RollOut1"
(spinner spn_r1
on spn_r1 changed value do
	(
		 m=spn_r1.value
		spn_r1.value = m
	)
)
rollout r2 "RollOut2"
(spinner spn_r2
on spn_r2 changed value do
	(
		spn_r2.value = m
	)
)
nf = newRolloutFloater "Example 2: Floater spinners" 225 115
addRollout r1 nf
addRollout r2 nf
)

My question is, is there any way to get the spinners in Example 2 to behave in the same ways as in Example 1? I understand that the floater is basically just a wrapper for the two rollouts and that, as such, the rollouts aren’t aware of each other’s existence. I’ve tried any number of finagles and can’t get them to interact with each other. Any advice would be greatly appreciated. Thanks.

4 Replies

Could you try referencing the UI elements through the rollout…

So if you have a rollout called “Rollout1” with a spinner called “Spn_A” then you can reference it using Rollout1.spn_A.value. This can also be done through the floater… as in
nf.Rollout1.Spn_A

I dont max infront of me, but your code might work a little something like…


(
local r1,r2,nf

rollout r1 "RollOut1"
(
spinner spn_r1
on spn_r1 changed val do
	(
	nf.r2.spn_r2.value = val
	)
)
rollout r2 "RollOut2"
(
spinner spn_r2
on spn_r2 changed val do
	(
	nf.r1.spn_r1.value = val
	)
)
nf = newRolloutFloater "Example 2: Floater spinners" 225 115
addRollout r1 nf
addRollout r2 nf
)


Does this help at all? As I said, I have no max, so I cannot test it, and there might be a lot nicer way of doing it!

Good luck,

Rich

Thinking about it again, I you can only refernence the rollouts on a floater through the “.rollouts” property, which yields an array of your rollouts, which would mean the code would look like this!



(
local nf,r1,r2

rollout r1 "RollOut1"
(
spinner spn_r1
on spn_r1 changed val do
	(
	nf.rollouts[2].spn_r2.value = val
	)
)
rollout r2 "RollOut2"
(
spinner spn_r2
on spn_r2 changed val do
	(
	nf.rollouts[1].spn_r1.value = val
	)
)
nf = newRolloutFloater "Example 2: Floater spinners" 225 115
addRollout r1 nf
addRollout r2 nf

)


I this is right, then my first post will probably just kick up an error saying there is no “.r1” property in a floater… or something like that…

cheers,

Rich

That second bit works smooth as silk, EverZen. Thanks!:applause:

Just as follow-up to this, in a parallel thread over at the Area forum, Caprier and David “stokes” Stokes pointed out that if the rollouts are declared as variables at the opening of the script, then they can be referenced directly rather than through a .rollouts array ref…


( 
local m, r1, r2

rollout r1 "RollOut1"
(spinner spn_r1
on spn_r1 changed value do
	(
		m = spn_r1.value
  r2.spn_r2.value = m
	)
)
rollout r2 "RollOut2"
(spinner spn_r2
on spn_r2 changed value do
	(
		m = spn_r2.value
  r1.spn_r1.value = m
	)
)
nf = newRolloutFloater "Example 2: Floater spinners" 225 115
addRollout r1 nf
addRollout r2 nf
) 

Thanks again to all.