Class: Toybox::WatchUi::Button

Inherits:
Selectable show all

Overview

Note:

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

A representation of a Selectable button.

Button objects are mappable to a BehaviorDelegate method on selection.

See Also:

Since:

  • 2.1.0

App Types:

  • Watch Face

  • Widget

  • App

  • Audio Content Provider App

  • Background Services

Instance Attribute Summary collapse

Attributes inherited from Selectable

stateDefault, stateDisabled, stateHighlighted, stateSelected

Attributes inherited from Drawable

height, identifier, locX, locY, width

Instance Method Summary collapse

Methods inherited from Selectable

getState, setState

Methods inherited from Drawable

setLocation, setSize

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(settings) ⇒ Button

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

Parameters:

Options Hash (settings):

Since:

  • 2.1.0


14516
14517
# File 'Monkeybrains.rb', line 14516

def initialize(settings)
end

Instance Attribute Details

backgroundToybox::Lang::Object

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.

Returns:

Since:

  • 2.1.0


14489
14490
14491
# File 'Monkeybrains.rb', line 14489

def background
  @background
end

behaviorToybox::Lang::Symbol

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 false or null, then a SelectableEvent will be issued.

Returns:

See Also:

Since:

  • 2.1.0


14501
14502
14503
# File 'Monkeybrains.rb', line 14501

def behavior
  @behavior
end

Instance Method Details

draw(dc) ⇒ Object

Draw the Button to the device context (Dc).

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

Parameters:

Since:

  • 2.1.0


14525
14526
# File 'Monkeybrains.rb', line 14525

def draw(dc)
end