Button

extendsLabel โ†’ DisplayObject โ†’ Object

Like Label but with material button appearance and effect. This widget is designed to be clicked or touched by users. Thus, we recommend to use this as user's input interaction instead of Label. Here is the example to add action when user tap or click the button:

...
<Button
text="Example Button"
onSelect="@stage/myListener"/>
...

and This is the event listener:

...
<event on="created">
this.myListener = function() {
// Your action here when button clicked or tap
}
</event>
...

Properties#

nameTypeDefault ValueDescription
paddingTopstring or number"16dp"Can be either plain number or number with unit.
paddingBottomstring or number"16dp"Can be either plain number or number with unit.
paddingLeftstring or number"16dp"Can be either plain number or number with unit.
paddingRightstring or number"16dp"Can be either plain number or number with unit.
paddingHorizontalstring or number"16dp"Set this to write both paddingLeft and paddingRight at once.
paddingVerticalstring or number"16dp"Set this to write both paddingTop and paddingBottom at once.
paddingsstring or number"16dp"Set this to write paddingTop, paddingBottom, paddingLeft and paddingRight.
elevationstring or number"8dp"Can be either plain number or number with unit.
cornerRadiusstring or number"8dp"Can be either plain number or number with unit.
backgroundColornumberapp.res.style.secondaryColorUse app.colors.* to set the color.
textColornumberapp.res.style.onSecondaryColorUse app.colors.* to set the color.
rippleColornumber0xdf000000Overlay color of ripple effect when user tap or click. Use app.colors.* to set the color.

Inherited from Label#

nameTypeDefault ValueDescription
textstring""Text that going to be displayed
textSizestring or numberapp.res.style.controlTextSizeCan be either plain number or number with unit.
widthstring or number"content"Can be number, number with unit, "content", or "container". see sizing guide.
heightstring or number"content"Can be number, number with unit, "content", or "container". see sizing guide.
boldbooleanfalseSet true to make the text bold.
italicbooleanfalseSet true to make the text italic.
underlinebooleanfalseSet true to make the text underline.
wrapbooleantrueKeep this true to let the excess text move to the new line.
alignTextstring""Align position of this widget. See alignment guide.
fontTypestring""Set this to desired font file name for custom typography or ignore this to use default font.

Inherited from DisplayObject#

nameTypeDefault ValueDescription
idstring(8-digit random)Identifies widget. Set this to make it searchable.
xstring or number0Can be either plain number or number with unit.
ystring or number0Can be either plain number or number with unit.
scaleXnumber1.0Fraction of number. This will multiply width.
scaleYnumber1.0Fraction of number. This will multiply height.
scalenumber1.0Set this to change both scaleX and scaleY at once.
alphanumber1.00.0 means transparent and 1.0 is fully opaque.
anglenumber00.0 means transparent and 1.0 is fully opaque.
presencebooleantrueIf true, this widget will affects other widgets' position and size.
visiblebooleantrueIf true, this widget will be drawn.
clippingbooleantrueIf true, content of this widget will be cropped if exceed the boundary.
suspendUpdatebooleantrueSet true to temporarily prevent update trigger.
foregroundColornumberapp.res.style.foregroundColorUse app.colors.* to set the color.
borderColornumberthis.foregroundColorUse app.colors.* to set the color.
borderSizestring or number0Can be either plain number or number with unit.
marginTopstring or number0Can be either plain number or number with unit.
marginBottomstring or number0Can be either plain number or number with unit.
marginLeftstring or number0Can be either plain number or number with unit.
marginRightstring or number0Can be either plain number or number with unit.
marginHorizontalstring or number0Set this to write both marginLeft and marginRight at once.
marginVerticalstring or number0Set this to write both marginTop and marginBottom at once.
marginsstring or number0Set this to write marginTop, marginBottom, marginLeft and marginRight.
alignSelfstring""Align position of this widget. See alignment guide.
hookTopToTopOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookTopToBottomOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookBottomToBottomOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookBottomToTopOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookLeftToLeftOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookLeftToRightOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookRightToRightOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookRightToLeftOfstring""ID of targeted widget. Only works if currently content of HookLayout.
onDrawfunction(empty function)Event listeners that you could set on .fiwl layout.
onUpdatefunction(empty function)Event listeners that you could set on .fiwl layout.
onSelectfunction(empty function)Event listeners that you could set on .fiwl layout.
onOptionfunction(empty function)Event listeners that you could set on .fiwl layout.
onScrollfunction(empty function)Event listeners that you could set on .fiwl layout.
onDragStartfunction(empty function)Event listeners that you could set on .fiwl layout.
onDragMovefunction(empty function)Event listeners that you could set on .fiwl layout.
onDragEndfunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverStartfunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverMovefunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverEndfunction(empty function)Event listeners that you could set on .fiwl layout.
onAsyncCreatefunction(empty function)Event listeners that you could set on .fiwl layout.
onReadyfunction(empty function)Event listeners that you could set on .fiwl layout.
onSuspendfunction(empty function)Event listeners that you could set on .fiwl layout.
onDestroyfunction(empty function)Event listeners that you could set on .fiwl layout.

Read-only Properties#

Inherited from Label#

NameTypeDescription
measuredContentsWidthnumberMeasured width = "contents" value.
measuredContentsHeightnumberMeasured height = "contents" value.

Inherited from DisplayObject#

NameTypeDescription
containerobjectGet this instance's container. See Layout Principle.
globalXnumberGet pre-calculated absolute horizontal position.
globalYnumberGet pre-calculated absolute vertical position.
measuredWidthnumberGet pre-calculated absolute width.
measuredHeightnumberGet pre-calculated absolute height.

Methods#

Inherited from DisplayObject#

NameReturn TypeDescription
requestUpdatevoidManually request to re-render.
addEventListenervoidCalls app.event.addEventListener with this widget as context.
removeEventListenervoidCalls app.event.removeEventListener with this widget as context.