close rollout

Hi,
I have two rollout.
I want to close them. So I use :

if (RF.dialogBar == true) do
			(
			cui.UnRegisterDialogBar RF
			closeRolloutFloater RF 
			)
if (RFB.dialogBar == true) do
			(
			cui.UnRegisterDialogBar RFB
			closeRolloutFloater RFB 
			)

It works when I use script, but not with macroscript.
Any idea ? Thanks.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

You can make a single global struct that holds information about all of your rollout floaters defined in various scripts
and then you can access all of them using single global variable
example:

(
-- if structure already exists then just call titane357.AddRolloutFloater whenever new rollout floater is created (titane357 structure must be created only once)
global titane357 =
(
	local owner
	struct titane357
	(
		rollout_floaters = #(),
 
		fn CloseRolloutFloater rollout_title = 
		(
 
			for i = rollout_floaters.count to 1 by -1 where (stricmp rollout_title rollout_floaters[i].title) == 0 do
			(				
				try closeRolloutFloater rollout_floaters[i] catch()
				try cui.UnRegisterDialogBar rollout_floaters[i] catch()
				deleteItem owner.rollout_floaters i
			)
		),
 
		fn AddRolloutFloater floater =
		(
			if isKindOf floater RolloutFloater do append rollout_floaters floater			
		),
 
		on create do owner = this
 
	)
 
	titane357()
)
 
 
-- define some rollout
rollout X ""
(
	button btn "btn"
)
 
-- make a floater
my_floater = newRolloutFloater "titane357 floater" 300 220
addRollout X my_floater
 
-- register this floater in titane357 structure
titane357.AddRolloutFloater my_floater
 
 
-- print all registered floaters
format "Floaters: %\n"  titane357.rollout_floaters
sleep 1.0
-- Now close and unregister particular floater. This can be done from any macro or script since titane357 is a global variable and all of its properties and methods are public
titane357.CloseRolloutFloater "titane357 floater"
-- floater's gone
format "Floaters: %\n" titane357.rollout_floaters
)
titane357's picture

I jahman, thanks for your

I jahman, thanks for your answer. Let me just 2 months to undestand what you mean... :-)

titane357's picture

oookey...I manage to do it

oookey...
I manage to do it :
Rollout declared as global.
And made a macroscript to run my script (as for .mse).
It works. If anybody can explain I would be happy ! :-)
I add to my script "try" and "catch" because if one (or both) rollout isn't active I got error.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.