Button Component


Properties

backgroundColor
  Specifies the Button's background color as an RRGGBBAA red-gren-blue-alpha integer. If an Image has been set, the color change will not be visible until the Image is removed.
Data type: color
Designer Writable true <button name="buttonName" backgroundColor="FFd3893f">
Code Writeable true buttonName.backgroundColor = "FFd3893f"
Code Readable true let variable = buttonName.backgroundColor

enabled
  Specifies whether the Button should be active and clickable.
Data type: boolean
Designer Writable true <button name="buttonName" enabled="true">
Code Writeable true buttonName.enabled = true
Code Readable true let variable = buttonName.enabled

fontBold
  Specifies whether the text of the Button should be bold. Some fonts do not support bold.
Data type: boolean
Designer Writable true <button name="buttonName" fontBold="true">
Code Writeable true buttonName.fontBold = true
Code Readable true let variable = buttonName.fontBold

fontItalic
  Specifies whether the text of the Button should be italic. Some fonts do not support italic.
Data type: boolean
Designer Writable true <button name="buttonName" fontItalic="true">
Code Writeable true buttonName.fontItalic = true
Code Readable true let variable = buttonName.fontItalic

fontSize
  Specifies the text font size of the Button, measured in sp(scale-independent pixels).
Data type: number
Designer Writable true <button name="buttonName" fontSize="12">
Code Writeable true buttonName.fontSize = 12
Code Readable true let variable = buttonName.fontSize

fontTypeface
  Specifies the text font face of the Button as 'serif', 'sans serif', or 'monospace'.
Data type: string
Designer Writable true <button name="buttonName" fontTypeface="monospace">
Code Writeable false
Code Readable false

height
  Specifies the Button's vertical height, measured in pixels.
Data type: number
Designer Writable true <button name="buttonName" height="48">
Code Writeable true buttonName.height = 48
Code Readable true let variable = buttonName.height

heightPercent
  Specifies the Button's vertical height as a percentage of the Screen's Height.
Data type: number
Designer Writable false
Code Writeable true buttonName.heightPercent = 12
Code Readable false

image
  Specifies the path of the Button's image. If there is both an Image and a BackgroundColor specified, only the Image will be visible.
Data type: string
Designer Writable true <button name="buttonName" image="cat.png">
Code Writeable true buttonName.image = "cat.png"
Code Readable true let variable = buttonName.image

shape
  Specifies a the shape of the Button. The valid values for this property are 'round', 'rectangle', and 'oval'. The Shape will not be visible if an Image is used.
Data type: string
Designer Writable true <button name="buttonName" shape="oval">
Code Writeable false
Code Readable false

showFeedback
  Specifies if a visual feedback should be shown when a Button with an assigned Image is pressed.
Data type: boolean
Designer Writable true <button name="buttonName" showFeedback="true">
Code Writeable true buttonName.showFeedback = true
Code Readable true let variable = buttonName.showFeedback

text
  Specifies the text displayed by the Button.
Data type: string
Designer Writable true <button name="buttonName" text="Test text">
Code Writeable true buttonName.text = "Test text"
Code Readable true let variable = buttonName.text

textAlignment
  Specifies the alignment of the Button's text. Valid values are 'left', 'center' and 'right'
Data type: string
Designer Writable true <button name="buttonName" textAlignment="left">
Code Writeable false
Code Readable false

textColor
  Specifies the text color of the Button as an red-green-blue-alpha RRGGBBAA or red-green-blue RRGGBB string.
Data type: color
Designer Writable true <button name="buttonName" textColor="FF8ce1e0">
Code Writeable true buttonName.textColor = "FF8ce1e0"
Code Readable true let variable = buttonName.textColor

visible
  Specifies whether the Button should be visible on the screen. Value is true if the Button is showing and false if hidden.
Data type: boolean
Designer Writable true <button name="buttonName" visible="true">
Code Writeable true buttonName.visible = true
Code Readable true let variable = buttonName.visible

width
  Specifies the horizontal width of the Button, measured in pixels.
Data type: number
Designer Writable true <button name="buttonName" width="180">
Code Writeable true buttonName.width = 180
Code Readable true let variable = buttonName.width

widthPercent
  Specifies the horizontal width of the Button as a percentage of the Screen's Width.
Data type: number
Designer Writable false
Code Writeable true buttonName.widthPercent = 50
Code Readable false

class
  The styling class of the the component
Data type: string
Designer Writable true <button name="buttonName" class="Test class">
Code Writeable false
Code Readable false

id
  The styling id of the the component
Data type: string
Designer Writable true <button name="buttonName" id="Test id">
Code Writeable false
Code Readable false

name
  The name of the component that will be used to refer to it in code.
Data type: string
Designer Writable true <button name="buttonName" name="testComponent">
Code Writeable false
Code Readable false

Methods

Method name Description Parameters
addEventListener Method used to create event listeners.
See Events below for samples.
eventName string
eventCallbackFunction callback

Events

Event name Description Parameters
click Indicates that the user tapped and released the Button.
buttonName.addEventListener(
    "click",
    function () {
        //Your code here
    }
)
gotFocus Indicates the cursor moved over the Button so it is now possible to click it.
buttonName.addEventListener(
    "gotFocus",
    function () {
        //Your code here
    }
)
longClick Indicates that the user held the Button down.
buttonName.addEventListener(
    "longClick",
    function () {
        //Your code here
    }
)
lostFocus Indicates the cursor moved away from the Button so it is now no longer possible to click it.
buttonName.addEventListener(
    "lostFocus",
    function () {
        //Your code here
    }
)
touchDown Indicates that the Button was pressed down.
buttonName.addEventListener(
    "touchDown",
    function () {
        //Your code here
    }
)
touchUp Indicates that the Button has been released.
buttonName.addEventListener(
    "touchUp",
    function () {
        //Your code here
    }
)