[Closed] need an action when closing a RolloutFloater
Does anyone know if there’s a way to have your script execute some final actions once the user has clicked the “X” button (in the upper right) to close the rollout floater?
Thanks!!!
Hi, you can use the “on rollout close” event handler:
rollout rolTest "test"
(
on rolTest close do
(
print "rollout final action"
)
)
createDialog rolTest 100 100
- Enrico
Enrico,
Thanks, but if I’m not mistaken this applies only to createDialog windows which have event handlers for open, close, etc. In my case though I’m using the newRolloutFloater and I couldn’t find any thing the reference file indicating there are event handlers for them.
Yep, you’re right, so I came up with a question and a not so good but probably working option:
Why do you need a Rollout Floater and don’t use a Create Dialog? I mean if the issue is having many rollouts inside it, you can simply create a main Rollout holding a single SubRollout, then insert in it every Rollout you like.
The hacky solution for the Rollout Floater is the use of a timer. Since the Rollout Floater is created in the global scope, you can create it and start a timer to check if it is open. When the Floater is closed, the <rolloutFloater>.open returns false and you perform your final action and stop the timer. Not the ideal, but should work.
- Enrico
rollout events work for any rollout, and it doesn’t matter where it is (dialog, floater, custAttr, scripted plugin, utility, etc.). Pick any rollout from your floater to do anything on its close event.
rollout r1 "1" rolledup:on
(
on r1 open do format "1 is opened
"
on r1 close do format "1 is closed
"
)
rollout r2 "2" rolledup:on
(
on r2 open do format " 2 is opened
"
on r2 close do format " 2 is closed
"
)
rollout r3 "3" rolledup:on
(
on r3 open do format " 3 is opened
"
on r3 close do format " 3 is closed
"
)
rf = newRolloutFloater "Rollouts" 200 70
addRollout r1 rf
addRollout r2 rf
addRollout r3 rf
Well, this is kinda strange. The “on rollout close” is a rollout event indeed. But before posting I tried putting it into a Rollout Floater and it didn’t fire the “on close” even when the floater was closed, so came up with the workaround. Don’t know what happened on my machine, but I’m glad there’s a better solution.
- Enrico
I’ll be damned… DenisT, thanks so much! Good to know. I wouldn’t have assumed that’s the case… works perfectly though!
SyncViewS, thanks for your efforts as well!