Class: Toybox.WatchUi.Button

Overview

A representation of a Selectable button.

Button objects are mappable to a BehaviorDelegate method on selection.

See Also:

Note:

See the Selectable sample distributed with the SDK for an example of the use of the Button class

Since:

API Level 2.1.0

App Types:

  • Watch App

  • Audio Content Provider

  • Background

  • Watch Face

  • Widget

Instance Member Summary collapse

Instance Method Summary collapse

Instance Attribute Details

var background as Graphics.ColorType or WatchUi.Drawable or Null

The Button background

A Drawable, Graphics.COLOR_* value, or 24-bit integer of the form 0xRRGGBB to be drawn before the current Selectable state is drawn.

Since:

API Level 2.1.0

Returns:

var behavior as Lang.Symbol or Null

A Symbol describing the behavior method executed when button is selected.

This Symbol must be a member of the active View object's registered BehaviorDelegate, such as :onBack, but may also be a Symbol from an extended class. If the value is null, then a SelectableEvent will be issued.

Since:

API Level 2.1.0

See Also:

Returns:

Instance Method Details

draw(dc as Graphics.Dc) as Void

Draw the Button to the device context (Dc).

This method assumes that the device context has already been configured to the proper options.

Parameters:

Since:

API Level 2.1.0

initialize(options as { :behavior as Lang.Symbol, :background as Graphics.ColorType or WatchUi.Drawable, :locX as Lang.Numeric, :locY as Lang.Numeric, :width as Lang.Numeric, :height as Lang.Numeric, :stateDefault as Graphics.ColorType or WatchUi.Drawable, :stateHighlighted as Graphics.ColorType or WatchUi.Drawable, :stateSelected as Graphics.ColorType or WatchUi.Drawable, :stateDisabled as Graphics.ColorType or WatchUi.Drawable, :identifier as Lang.Object, :visible as Lang.Boolean })

Constructor Initializes a Button object's foreground, background, and behavior. The Button must be registered during setLayout() in order to be usable.

Parameters:

See Also:

Since:

API Level 2.1.0


Generated Dec 11, 2024, 8:58:44 AM