Working with MetaTypes
MetaTypes provide a powerful means of defining components (as MetaTypes) and then subclassing them in Pages, Sections and FormItems (Fields and Gadgets).
Select the "Pages" workspace.
Click the "MetaType Editor" icon in the HeaderBar at the top.
Create or edit MetaTypes.
Associate one or more (comma separated) MetaTypes with a UI Element by editing the "Meta types" in its "Attributes" Tab.
Each Page, Section, Field or Gadget has a "MetaTypes" attribute. This is a comma separated list which enables mutiple inheritance of MetaTypes. These are applied from left to right in the MetaTypes list.
MetaTypes are defined using the "MetaType Editor" which is activated when you click its icon in the project, app or page workspaces.
Each MetaType that you define in the MetaType Editor can contain many attribute/value pairs as well as delegates and their procedure/function names. So essentially a MetaType is a "class" which can be inherited simply by specifying its name in the "Meta Types" attribute for Pages, Sections and FormItems.
If you want to share MetaTypes across multiple apps then you should first of all create a project then add apps to the project. The MetaType Editor creates two files in the lianja\metatypes directory; a file with a .metatypes extension and a corresponding MetaType library with the same name but with an extension matching the scripting language for the app. The name of the MetaType file and the MetaType Library can be overwritten as these are in the App attributes.
It is important to understand that MetaTypes can be created for not just common UI elements but also for their delegates. This provides a scripting language independent method for subclassing UI components -- a common feature request from Lianja developers.
Using the MetaType Editor
To activate the MetaType Editor click its icon.
The MetaType Editor is now displayed on top of the App Builder main window.
To create a new MetaType click the "+" icon in the actionBar of the MetaType Editor.
Each MetaType must have a unique name.
You can select what attributes you want to view from the ComboBox at the top on the right side tree. Double click any attribute from the right hand side tree and it will be loaded into the EditPanel on the bottom left hand side.
Attributes can be simple Strings which are typed in, Numeric values which are typed in, Boolean values which are selected from a ComboBox, A list of values which are selected from a ComboBox, Colors which can be specified using a popup color dialog (click on the DialogButton '...'), or Delegates which are defined in a popup editor dialog (click on the DialogButton '...') which provides the ability to edit the MetaType Library associated with the MetaType file.
After defining MetaTypes specify them in the Page, Section or FormItem attributes.
One important thing to realize is that a MetaType can contain multiple attribute/values and delegate/procs for Pages, Sections and/or FormItems, all contained within the same MetaType. In the MetaType Editor attributes are made unique by prefixing them with "page.", "section." or "formitem." . This provides a powerful means of applying multiple attributes and delegates to an App across Pages, Sections and FormItems.
At any time while editing MetaTypes in the MetaType Editor you can apply the MetaTypes across all the UI elements of the current application by clicking the "Apply" button.
When an App is loaded (development or runtime) if it has a MetaType file specified in the App settings the MetaType file is opened and any types that are specified for Pages, Section or FormItems are applied to the App. If there is an associated MetaType Library this is loaded prior to the MetaTypes being processed.
How do I know what attributes and/or delegates are being applied to my App?
When MetaTypes are being applied to an App appropriate informational messages are written in the "Events" Tab of the App Inspector.
For Desktop Apps don't forget to include the MetaTypes files in your installer.
For Web and Mobile Apps the MetaTypes are applied to an App prior to it being deployed (when it is opened). The MetaType library will automatically be deployed.
If you have any questions about using MetaTypes please ask on the Lianja Developer Community Forums.