WsButton:
Filter:
WsGUI/Classes (extension) | GUI > WsGUI | Extensions

WsButton
ExtensionExtension

A multi-state button for WsGUI

Description

A multi-state button for WsGUI.

Class Methods

.new

Create new instance and add it to the window immediately.

.init

.init

Create new instance without adding it to the window. Use this when using WsLayout.

Arguments:

wsWindow

An instance of WsWindow

bounds

A Rect specifying the size of the widget.

NOTE: Currently a relative measurement is used: 1 for full window width, 1 for full window height, e.g. Rect(0, 0, 1, 1) would occupy whole window.

Returns:

an instance of the widget

Instance Methods

.states

An array of labels and colors defining the states of the button.

Arguments:

statesArray

An Array of arrays of the form [ [String, strColor, bgColor] , .... ]

.value

Sets the current state. Does not trigger the action.

Arguments:

val

An integer setting the state number.

.valueAction

Sets the current state and triggers the action.

Arguments:

val

An integer setting the state number.

.item

Returns:

Current state's text.

.action

Gets or sets function to be evaluated when the button is pressed.

Arguments:

function

Any object to set as default action, usually a Function. It is passed the current instance.

.string

Get/set a text content for applicable widgets.

Arguments:

thisString

A string to be set.

Returns:

current string

.align

Change alignment of the text.

Arguments:

align

Can be \left, \right, \center, \justify.

Returns:

Current alignment.

.font

Change the font of the text for applicable widgets.

Arguments:

font

An instance of Font. Size and font face are supported.

Returns:

Current font.

.addToPage

Add to window/page specified in *init.

.remove

Removes the widget from the window.

Examples