Widget Candy GENERAL WIDGET METHODS

Send Snippet To: Save this snippet to Code Collector Pro -- view all roger's snippets
language: Other
license: Other

Code for Snippet:

                
 
MyWidget:show ( state, fadeDuration )
 
state	(Boolean) Shows (true) or hides (false) the widget.
 
fadeDuration	(Number) If specified, the widget will smoothly fade in or out, using the specified duration for the fade effect.
—————————————
 
MyWidget:enable ( state )
 
state	(Boolean) Enables (true) or disables (false) the widget. If disabled, the widget will appear greyed-out and does not respond to user actions.
———————————
 
MyWidget:set ( "propertyName", value, includeChildren )
 
"propertyName"	(String) Name of a widget property (in quotes).
See Widget Properties for a list of valid widget properties.
 
value	(Any) Any value to set the specified property to.
includeChildren	(Boolean) If true and the widget is a container widget (a window, for example), this command will be applied to all child widgets, too.
 
Example	MyWidget:set("caption", "My new caption!")
—————————————
 
 
MyWidget:set ( Table )
 
Table	(Table) A widget's :set() method can also be used to change several properties at once. To do so, simply pass a table that contains any property-value pairs.
See Widget Properties for a list of valid widget properties.
 
Example	Widget:set( { caption = "My new caption!", icon = 1, textAlign = "left" } )
——————————————
 
 
MyWidget:get ( "propertyName" )
 
"propertyName"	(String) Name of a widget property (in quotes) that you want to retrieve.
See Widget Properties for a list of valid widget properties.
 
Example	local txt = MyWidget:get( "caption" )
————————————————
 
 
MyWidget:setPos ( x, y )
 
x	The widget's x-position. You can use either "left", "right", or "center", as well as percentage values from "0%" to "100%" (in quotes) or any number. 
See here for more info on widget position values.
 
y	The widget's y-position. You can use either "top", "bottom", or "center", as well as percentage values from "0%" to "100%" (in quotes) or any number. 
See here for more info on widget position values.
 
Example	MyWidget:setPos( "top", "left" )
—————————————————
 
MyWidget:getShape ()
 
Returns:	A table with four properties: .x, .y, .w and .h which determine the top left corner, width and height of this widget (as seen from its' parent's coordinate system).
 
Example	local Bounds = MyWidget:getShape(); print (Bounds.x)
 
—————————————————————————
 
MyWidget:getDepth ()
 
Returns:	(Number) Returns the z-index (drawing order) of the widget. This method is useful if you want to place a widget behind or in front of another one. Widgets with lower z-indexes will be drawn behind widgets with a higher z-index.
 
Example	local zindex = MyWidget:getDepth()
—————————————————
 
 
MyWidget:toFront ()
 
Brings the widget to front, so the widget will be drawn on top of all other widgets sharing the same parent.
————————————
 
MyWidget:update ()
 
Updates (redraws) the entire widget. Use this method if you changed any widget property which is not reflected instantly. Using :update() is always a good idea here, but should be used wisely, because redrawing an entire widget will cost some performance, of course.
—————————————————
 
MyWidget:destroy ()
 
Removes (deletes) a widget. Do not forget to set any stored references to this widget to nil again, otherwise the widget could not be garbage collected correctly and would still remain in memory.
———————————————————
 
 
MyWidget:makeDraggable (minX,minY, maxX,maxY)
 
Makes a widget draggable by the user within a specified bounding box (defined by minX, minY, maxX and maxY). Can be used with all widgets, except the window widget (which is already draggable). To disable drag functionality, simply call :makeDraggable(false).
 
***********
comments powered by Disqus

Info

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 22
Date Added: 2018-01-10 15:12:05
Last Modified: 2018-01-10 09:54:13

Web Analytics