2Creating a LiveCode Builder Widget
Just like libraries widgets are written in a text editor.
Start by creating a plain text file in a new directory and save it to disk with the extension “.lcb”.
I am naming my file “rotatedText.lcb” but you can name your file anything suitable.
Note: The extension builder currently relies on there being only one .lcb file in a given directory, this is why we create a separate folder for each new extension.
LCB widget definition
The first thing we need to do is declare the type of extension we are writing.
We are writing a widget so we need to declare the extension as such.
The widget declaration is followed by an identifier. An extension identifier should be in the form
In my case my username is “elanorb” and I have chosen to use “rotatedtext” as the name part of the identifier.
For more on module naming see the ‘Naming’ section of the LiveCode Builder Style Guide, accessible from the Dictionary stack or the Additional Resources section of this course.
Add the widget definition to the source file.
Widget Metadata
As with an LCB library, widgets also require metadata.
The required metadata for widgets is the same as for libraries
- title
- author
- version
You can also include an optional description.
Add the widget metadata to the definition.
 metadata author is "Elanor Buchanan" metadata version is "1.0.0" end widget
LCB modules
The LiveCode builder syntax is broken down into modules. Each module contains the syntax for a particular part of LiveCode Builder.
You include the modules that provide the syntax for the features your extension requires.
There are 3 classes of module:
- Default: These modules are part of LiveCode builder and are included by default. Their syntax is always available to you as a LiveCode developer.
- OptionalThese modules are created and distributed by LiveCode Ltd and must be imported by the extension developer in order to make use of their syntax.
- CustomThese modules are created and distributed through the online portal and must be imported by the extension developer in order to make use of their syntax.
For a full list of modules see the ‘Importing Libraries’ section of the Extending LiveCode Guide and the API entries for the individual modules. The guide can be found under the Guides tab of the Dictionary or in the Additional Resources section of the course.
Including Modules
As a general rule we recommend importing all three optional modules and the Widget Utilities library whenever developing widgets.
Include the 3 modules and 1 library using the use keyword, followed by the module or library extension.
use com.livecode.engine metadata title is "Rotated Text" metadata author is "Elanor Buchanan" metadata version is "1.0.0" end widget