-
Notifications
You must be signed in to change notification settings - Fork 8
Main Widget Class
Marcus Mascord edited this page Jul 15, 2014
·
4 revisions
All of the Widgets inherit from the Widget Class. In JavaScript inheritance does not exist as we know it in Java, so instead of inheritance association has been used.
Every widget has an attribute called "m". "m" points to the widget class. The widget class holds the common attributes.
For example one of the attributes in the widget class is "hidden". When "hidden" is set to true, the widget is not shown to the user. In JavaScript to set "hidden" to true it is necessary to include the "m" attribute. So the code will be:
myWidget.m.hidden = true;
However in the XML, it is not necessary to refer to the "m" attribute. The attribute can be written directly in the widget as:
<Widget>
<Id>myWidget</Id>
<Hidden>True</Hidden>
</Widget>
The attributes that are available in the Widget Class are:
Attribute | Type | Description |
---|---|---|
id | String | This is the ID of the Widget. |
type | String | This is the type of the widget. This is so a developer can associate any type to the widget and this can help group the widgets. This is used a lot in drop and drag and animations. |
className | String | This is the class name of the widget and it should not be changed. |
parent | Widget | This points to the parent widget of this widget. The only Widget that has a parent set to null is the Screen widget. |
x | String | This is the x position of this widget within its parent. It can be a pixel value or a percentage. A pixel value is written as "10" and a percentage as "40%". |
y | String | This is the y position of this widget within its parent. It can be a pixel value or a percentage. A pixel value is written as "10" and a percentage as "40%". |
w | String | This is the width of the widget within its parent. It can be a pixel value or a percentage. A pixel value is written as "100" and a percentage as "50%". |
h | String | This is the height of the widget within its parent. It can be a pixel value or a percentage. A pixel value is written as "100" and a percentage as "50%". |
l | Integer | This is the layer of this widget within its parent. A widget with a higher layer number is drawn over a widget with a lower layer number. |
enabled | Boolean | The default value is true. The click action of a widget will be executed when this is set to true, however when this is set to false a click action of a widget will not be executed. |
widgets | Array of widget | These are the child widgets that belong to this widget. Only container widgets can have child widgets. |
calculateWidgetsPosFromScreen | Boolean | The default is false. If this is set to true, the position of the widgets are calculated from the screen and not the parent widget. |
hidden | Boolean | The default is false. If hidden is set to true, then the widget will not be visible on the screen. |
realX | Integer | Stores the realX value in pixels from the screen widget so actual position is realX + x. Read only. |
realY | Integer | Stores the realY value in pixels from the screen widget so actual position is realY + y. Read only. |
associatedObject | Object/Function | Can be used by the developer to attach an object/function to this widget. This could be a data transfer object, a database row or an id etc. |
onHoldMovingRedrawPartial | Boolean | Default is false. When set to true will only draw this widget that is on hold moving, otherwise will redraw all widgets. |
onActionRedrawPartial | Boolean | Default is false. When set to true on click action only draws this widget, if set to false will redraw all widgets on the screen. |
propogateClick | Boolean | Default is false. If propagate click is true, then the click will be sent to widgets that are directly under this widget on the screen. Imagine that you have 3 button widgets on top of each other all with propogateClick set to true, the click action of all of these button widgets will be executed for a single click. If set to false only the top click is accepted, others below are ignored. |
propogateHold | Boolean | Default is set to true. If propagate hold is true, then the hold under this widget is propagated. |
propogateOnDrop | Boolean | Default is set to true. IF propagate on drop is true, then the drop will propagate down. |
texts | Array of Text Widget | Array of text widgets, that are drawn over this widget. Any widget can have text widgets associated. A classic example is an Image widget used as a clickable icon, with text below. |
alignVert | Enum(TOP, BOTTOM, CENTER) | This aligns the widget vertically based on its parent. This will override the y value. |
alignHoz | Enum(LEFT, RIGHT, CENTER) | This aligns the widget horizontally based on its parent. This will overide the x value. |
alignSpacingVert | Integer | Default is 0. Spacing in pixels, to adjust alignVert. |
alignSpacingHoz | Integer | Default is 0. Spacing in pixels, to adjust alignHoz. |
alignIn | Boolean | Default is true. IF true, widget is drawn inside parent widget. If false widget is drawn outside parent widget. |