Introduction
The second type of extension that that be created is a widget. A widget is a custom control that is treated as an engine level element. Widgets appear in the Tools Palette and can be added as controls to any LiveCode stack.
The Rotated Text Widget displays text and allows the user to set the rotation property of the widget.
We will:
- Define the widget.
- Define properties for the widget.
- Draw the widget using LCB canvas operations.
- Compile and test the widget.
- Install the widget into LiveCode.
- Add the widget to a stack.
- Include the widget in a standalone.
What is the Canvas?
A canvas is a container that holds various drawing elements (lines, shapes, text, frames containing other elements, etc.). It takes its name from the canvas used in visual arts.
The main difference between a library and an extension is that a widget draws itself to the canvas, providing a UI element for the extension.
Advantages
Widgets have a number of advantages over traditional custom controls, created using LiveCode groups.
- Once built the widget it is an atomic control.
- Widgets are more efficient.
- Widgets are not affected by engine messages.
- Widgets can be easily updated by updating the extension without having to replace the controls on the stacks.