Widgets were introduced in LiveCode 8. Widgets add extensibility to the LiveCode control set by allowing anyone to create new, atomic controls for LiveCode. Widgets are more stable and efficient than custom controls created using groups. Widgets are also simple to install and use in LiveCode.
Widgets can be simple or complex and can provide a wide range of features and functionality.
You will see your set of widgets, both built-in and user installed, at the top of the Tools Palette.
Adding widgets to your stack
In this example we will add an SVG widget.
- Create a new mainstack
- Drag an SVG widget to the stack
- Drag the widget out to make it larger
- Open the Property Inspector for the widget
- Choose a preset path
- Set the rotation to 30
- Got to the Colors pane and set the Hilite color
Each widget will have a unique set of properties, defined by the developer who wrote the widget. There is a set of basic properties that all widgets have including name, visible, disabled, left, top, right, bottom, layer, textFont, textSize and some others.
Like classic controls, widgets also receive and can respond to messages. The messages that a widget receives are defined by the developer.
The SVG widget responds to mouseUp, but does not have any custom messages.
Open the Script Editor for the widget. You will see it has a default mouseUp handler which toggles the hilited state of the widget.
on mouseUp -- Toggle the hilited property when clicked set the hilited of me to (not the hilited of me) end mouseUp
Switch to Run mode and test it. The SVG widget should change color, from the normal color to the hilited color and back, when you click it and the hilited property toggles.
Including Widgets in Standalones
You need to make sure any widgets you use in your stack are included when you build a standalone.
If you leave your Standalone Application Setting on "Search for required inclusions" any widgets you used should be automatically included.
If you use "Select inclusions" make sure you go to the Inclusions pane and tick any widgets you want to include.