A button input element which executes a function when the button is pressed. Displays an image if provided, otherwise the text name is displayed. The button is assigned classname icon for CSS scripting.

Can be configured so the function is executed repeatedly when the button is held down. See repeatDelay and repeatFirst.

Implements

Constructors

  • Parameters

    • label: string

      name of the button

    • clickFunction: (() => void)

      the function to execute when button is clicked

        • (): void
        • Returns void

    • Optional opt_image: Node

      the image to show in the button; if undefined then the name is displayed as text.

    • Optional button: HTMLButtonElement

      the button to use; if not provided, then a button is created.

    Returns ButtonControl

Properties

clickFunction_: (() => void)

function to call when the button is clicked

Type declaration

    • (): void
    • function to call when the button is clicked

      Returns void

label_: string

the name of the button

repeatDelay: number = 0

When button is held down we fire the clickFunction repeatedly. This is the delay in milliseconds between firing of the clickFunction. Zero means only fire once. The default is zero.

repeatFirst: number = 2

The first repeatDelay should be longer to avoid unwanted held-button repeats. This is the multiplier used on the first delay.

timeoutID_: undefined | number

the ID used to cancel the callback

Methods

  • Returns the top level Element of this control. For example, this might be a label Element that encloses an input Element.

    Returns HTMLElement

    the top level Element of this control

  • This callback fires when the button is clicked.

    Parameters

    • _evt: Event

      the event that caused this callback to fire

    Returns void

  • This callback fires when a mouseUp or dragLeave occurs on the button.

    Parameters

    • _evt: Event

      the event that caused this callback to fire

    Returns void

  • Set a function to call when the button is clicked.

    Parameters

    • clickFunction: (() => void)

      the function to call when the button is clicked

        • (): void
        • Returns void

    Returns void

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc