Button creates a Button object for user to trigger an event or callback function.
Example - Default Size
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
btn = app.CreateButton( "Press Me" );
btn.SetOnTouch( SayHello );
lay.AddChild( btn );
app.AddLayout( lay );
}
function SayHello()
{
app.ShowPopup("Hello World!");
}
Example - Fixed size
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
btn = app.CreateButton( "Press Me", 0.5, 0.2 );
btn.SetOnTouch( SayHello );
lay.AddChild( btn );
app.AddLayout( lay );
}
function SayHello()
{
app.ShowPopup("Hello World!");
}
Example - Fill layout width
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
lay.SetPadding( 0.02, 0.02, 0.02, 0.02 );
btn = app.CreateButton( "Press Me", -1, -1, "FillX" );
btn.SetOnTouch( SayHello );
lay.AddChild( btn );
app.AddLayout( lay );
}
function SayHello()
{
app.ShowPopup("Hello World!");
}
Example - Change style
function OnStart()
{
lay = app.CreateLayout( "Linear", "Vertical,FillXY" );
lay.SetPadding( 0.1, 0.1, 0.1, 0 );
b1 = app.CreateButton( "Normal", -1, -1, "FillX" );
lay.AddChild( b1 );
b2 = app.CreateButton( "Gray", -1, -1, "FillX,Gray" );
lay.AddChild( b2 );
b3 = app.CreateButton( "Alum", -1, -1, "FillX,Alum" );
lay.AddChild( b3 );
app.AddLayout( lay );
}
The following methods are avaiable on the Button object:
GetPosition(
options ) ->
object - { left: fraction of parent width, top: fraction of parent height, right: fraction of parent width, bottom: fraction of parent height }
string
number - fraction of screen width
number - fraction of screen height
string - "custom" or "?"
number
set color effects
?
destroys object
destroys object with explode animation and sound
?
get height in pixels
get width in pixels
unknown
get screen relative height
get distance to left parent border
GetText
GetTextSize
get distance to upper parent border
GetVisibility
get screen relative width
Set visibility "Gone"
Set visibility "Hide"
IsEnabled
app object
return wether obj overlap with an other
IsVisible
?
string -
hexadecimal: "#rrggbb", "#aarrggbb"
colourName: "red", "green", ...
SetBackColor
SetBackColorRadial
string - path to file or folder ( "/absolute/..." or "relative/..." )
changes the background image
string - "Add" or "Multiply" or "?"
adjust color
?
boolean
en/disable object
change font style
string - html
allows using str_html formatting
move object from current position
function()
called when user touches object
function()
called when user touches object
set surrounding borders
SetPosition
number - factor
SetScale
change object size
number - integer
styling with custom option
SetText
change text str_col
SetTextShadow
SetTextSize
string - "Show" or "Hide" or "Gone"
change visibility mode
Set visibility "Show"
?
object id