mui.Setter

You can post your code snippets here for others to use and learn from
Post Reply
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

mui.Setter

Post by djrikki » Sun Apr 01, 2018 1:41 pm

This small function allows you to set an attribute to a value on multiple items in one function call, enjoy.

Remove the ExitOnError() block if you don't need it in your environment.

Code: Select all

Global Gui
Gui = {}

/* mui.Set */
Function Gui:Set(objects,attribute,value,postfix)
	ExitOnError(False)
	For i, v In IPairs(objects)
		mui.Set(v .. postfix,attribute,value)
	Next
	ExitOnError(True)
EndFunction
Example usage #1 - multiple items:

Code: Select all

Gui:Set({
	"evo_layout-foldall",
	"evo_layout-unfoldall",
	"evo_layout-remove-gadget"
},"disabled",True)
/* ForEach item in the array/table set the disabled attribute state to True */
Example usage #2 - single item:

Code: Select all

Gui.Set( {"evo_layout-foldall"} , "disabled" , True )
/* Remember the curly braces {} */
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com

djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: mui.Setter

Post by djrikki » Sun Apr 01, 2018 2:25 pm

And lastly, if it's a single item and you need to set multiple key/value pairs default back to using mui.Set().
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com

Post Reply