LiveCode
  • Why LiveCode?
  • Customers
  • Resources
  • Education
  • Consulting
  • Pricing
  • Blog
  • Login
  • Try LiveCode
Back to
  • slides
  • tutorial
Resources

Defining a Widget

Topic Progress:
← Back to Lesson

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.

newFile

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

community.livecode.<user name>.<widget name>

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 community.livecode.elanorb.rotatedtext

end widget

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.

widget community.livecode.elanorb.rotatedtext

metadata title is "Rotated Text" 
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.

widget community.livecode.elanorb.rotatedtext

use com.livecode.canvas
use com.livecode.widget
use com.livecode.engine
use com.livecode.library.widgetutils

metadata title is "Rotated Text"
metadata author is "Elanor Buchanan"
metadata version is "1.0.0"

end widget

← Previous Topic

← Previous Topic Next Topic →
  •  
  •  
  • (0)
  •  

Expand All | Collapse All
Lessons Status
1 - Hello World Library
  • Introduction
  • Installing a Text Editor
  • Creating an LCB library
  • LCB library definition
  • LCB handler definitions
  • Compiling and testing a library in LiveCode
  • LCB metadata
  • Installing an LCB Library
  • Packaging and sharing an LCB library
  • Including an LCB library in a standalone
  • Conclusion
2 - Extended Hello World Library
  • Introduction
  • Explicit Types
  • LCB Lists and Arrays
  • Type Conversion between LCB and LiveCode Script
  • Using Explicit Typing in the Library
  • Passing Parameters to the Library
  • Using Lists in the Library
  • Documenting the Library
  • Browsing the Documentation
  • Conclusion
3 - Rotated Text Widget
  • Introduction
  • Defining a Widget
  • LCB Module Level Variables
  • Widget Properties
  • Widget Handlers
  • LCB Canvas Operations
  • Compiling and Testing the Widget
  • Installing the Widget and adding it to a Stack
  • Including the Widget in a Standalone
  • Conclusion
4 - Extended Rotated Text Widget
  • Introduction
  • Integrating Properties
  • Accessing LiveCode Control Properties
  • Handling Mouse Events
  • Saving and Loading Widgets
  • Read Only Properties
  • Documenting the Widget
  • Conclusion
5 - Pie Chart Widget
  • Introduction
  • Planning the Widget
  • Widget Properties
  • The OnCreate Handler
  • The OnPaint Handler
  • Responding to Mouse Events
  • Saving and Loading the Widget
  • Installing and Including the Widget in a Standalone
  • Documenting the Widget
  • Conclusion
6 - Modifying the Line Graph Widget
  • Introduction
  • Duplicating the Line Graph Widget
  • Additional Color Properties
  • Filling the area below the line
  • Adding graph marker mouse events
  • Conclusion
7 - Additional Resources
  • Extending LiveCode Guide
  • LiveCode Builder Language Reference
  • LiveCode Builder Style Guide
  • LiveCode Documentation Format
 

LCB Source

LCB Source
 

Login

LiveCode

  • Why LiveCode?
  • Pricing
  • Customer Stories
  • Extensions
  • LiveCode in Education
  • LiveCode in Business

Looking for LiveCode FileMaker?

LiveCode for FM

Resources

  • Docs
  • API (Language Dictionary)
  • Lessons
  • Sample Stacks
  • Forums
  • Stackoverflow
  • User Groups
  • Support
  • Directory
  • LiveCode Services

About

  • About
  • Meet The Team
  • Careers at LiveCode
  • Contact us

Recent Posts

  • LiveCode Classic 10.0.1 Stable and 10.0.2-rc-1 Released
  • Create Progress – the Three D’s
  • LiveCode Create: Closing out the year with big steps forward
  • Create dp-5: Unified Engines and Shared Extensions
  • 3 Great New LiveCode Releases
Sitemap
Terms Privacy Policy EULA
Brought to you by LiveCode Ltd, Registered in Scotland, No. SC200728
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok