/app.lua:
-- create and add components directly
App:AddElement(Components.Base.Rectangle:new()) -- base components
App:AddElement(Components.Custom.HelloWorld:new()) -- custom components
-- OR
-- customize components before registering
hello_world_component = Components.Base.TextField:new()
hello_world_component.Label = "Hello World"
hello_world_component.PosX = 10
hello_world_component.PosY = 10
App:AddElement(hello_world_component)Canvas component is a work in progress
Components.Base.Canvas
A canvas to draw on.
PosXPosYWidthHeight
Text input box (with blinking cursor).
Components.Base.InputField
PosXPosYWidthValue(updated as you type)Type(string/number)Label(optional)LabelWidth(optional, 0 means auto)Color(as three-value-array or library reference (Lib.Colors.*))
Just a rectangle.
Components.Base.Rectangle
PosXPosYWidthHeightFill(boolean, whether to fill the rectangle)Color(as three-value-array or library reference (Lib.Colors.*))
Text box, can be used as a button as well.
Components.Base.Rectangle
PosXPosYLabel(actual text)Border(boolean, whether to draw a border)FontSize(7, 9, 10, 11, 12, 16, or 24)Color(as three-value-array or library reference (Lib.Colors.*))
The Update() function should return a boolean. The screen is only redrawn on update if at least one component's Update() function returns true.
Example:
Update: |
if self.Label == "Hello" then
self.Label = "Hello World"
end
return trueSupported data types: string, int, function, array, bool
You can access all keys in your functions using self.<key>.
Example:
MyKey1: "MyValue"
MyKey2: 30
MyFunc1: |
if self.MyKey2 == 30 then
self.MyKey1 = "Hello World"
endIf a key is detected to be int, bool or array, it is translated to the same type in Lua.
If you want to keep it a string (e. g. "0"), you have to define a *PreserveString key.
Example:
MyKey: "0"
MyKeyPreserveString: trueInherit: Base.InputField # which component to base on, either base or custom
Value: "0" # default values
Coordinate: "X1" # custom fields
Update: | # custom update function
App.Data.Var[self.Coordinate] = Value
return true