Skip to content

Latest commit

 

History

History
118 lines (97 loc) · 4.96 KB

Button.md

File metadata and controls

118 lines (97 loc) · 4.96 KB

Classes

ButtonControl

Interfaces

ButtonConfig

The configuration object for the Button class

ButtonKey

The configuration object for the ButtonKey class

ButtonStyle

The configuration object for the ButtonStyle class

ButtonConfig

The configuration object for the Button class

Kind: global interface
Properties

Name Type Description
id string

The id of the button (required)

text string

The text of the button (if not specified, it will be "TEXT")

width number

The width of the button (if not specified, it will be the length of the text + 4)

height number

The height of the button (if not specified, it will be 3)

x number

The x position of the button (required)

y number

The y position of the button (required)

style ButtonStyle

The style of the button (if not specified, it will be { background: "bgBlack", borderColor: "white", color: "white", bold: true })

key ButtonKey

The key to press to trigger the button

onClick function

The function to call when the button is clicked

onRelease function

The function to call when the button is released

visible boolean

If the button is visible or not (default: true)

enabled boolean

If the button is enabled or not (default: true)

draggable boolean

If the button is draggable or not (default: false)

ButtonKey

The configuration object for the ButtonKey class

Kind: global interface
Properties

Name Type Description
name string

The name of the key (required)

ctrl boolean

If the key is pressed with the ctrl key (default: false)

shift boolean

If the key is pressed with the shift key (default: false)

ButtonStyle

The configuration object for the ButtonStyle class

Kind: global interface
Properties

Name Type Description
background BackgroundColorName | HEX | RGB | ""

The background color of the button (if not specified, it will be "bgBlack")

borderColor ForegroundColorName | HEX | RGB | ""

The border color of the button (if not specified, it will be "white")

color ForegroundColorName | HEX | RGB | ""

The text color of the button (if not specified, it will be "white")

bold boolean

If the text is bold or not (default: true)

italic boolean

If the text is italic or not (default: false)

dim boolean

If the text is dim or not (default: false)

underline boolean

If the text is underlined or not (default: false)

inverse boolean

If the text is inverted or not (default: false)

hidden boolean

If the text is hidden or not (default: false)

strikethrough boolean

If the text is strikethrough or not (default: false)

overline boolean

If the text is overlined or not (default: false)

Button ⇐ Control

Kind: global class
Extends: Control

new Button(config)

This class is an overload of Control that is used to create a button.

Button

Emits the following events:

  • "click" when the user confirm
  • "relese" when the user cancel
Param Type Description
config ButtonConfig

The configuration object

Example

new Button({
        id: "btnRun", 
        text: "Run me!", 
        x: 21, 
        y: 18,
        style: {
            color: "magentaBright",
            bold: true,
            italic: true,
            borderColor: "green"
        },
        onRelease: () => {
            GUI.log("Button clicked!")
        },
        draggable: true,
    })