Class: Toybox.WatchUi.ToggleMenuItem

Overview

A representation of a toggle item in a Menu2.

A ToggleMenuItem is a element of a Menu2 View that represents one of the options in the menu, and includes an indicator on the menu item that appears in one of two states: enabled or disabled. When selected, the state of the ToggleMenuItem changes to the state opposite of the state prior to the onSelect delegate callback invocation.

A ToggleMenuItem can be added to a Menu2 using the addItem() method.

See Also:

Since:

API Level 3.0.0

Supported Devices:

Instance Method Summary collapse

Instance Method Details

getSubLabel() as Lang.String or Lang.Dictionary<Lang.Symbol, Lang.String or Null> or Null

Get a ToggleMenuItem label substring.

Returns:

Since:

API Level 3.0.0

initialize(label as Lang.String or Lang.ResourceId, subLabel as Lang.String or Lang.ResourceId or { :enabled as Lang.String or Lang.ResourceId or Null, :disabled as Lang.String or Lang.ResourceId or Null } or Null, identifier as Lang.Object or Null, enabled as Lang.Boolean, options as { :alignment as MenuItem.Alignment, :icon as Graphics.BitmapType or WatchUi.Drawable or Lang.ResourceId } or Null)

Constructor

Note:

The :icon option is only used on ConnectIQ 3.4.0 devices with subscreen support.

Parameters:

Since:

API Level 3.0.0

isEnabled() as Lang.Boolean

Get a ToggleMenuItem state.

Returns:

Since:

API Level 3.0.0

setEnabled(enabled as Lang.Boolean) as Void

Set a ToggleMenuItem state.

Parameters:

  • enabled(Lang.Boolean)

    The intended state of the ToggleMenuItem; enabled if true, disabled if false

Since:

API Level 3.0.0

Throws:

setSubLabel(subLabel as Lang.String or Lang.ResourceId or { :enabled as Lang.String or Lang.ResourceId or Null, :disabled as Lang.String or Lang.ResourceId or Null } or Null) as Void

Set a ToggleMenuItem label substring.

Parameters:

  • subLabel(Lang.String, Lang.ResourceId, Lang.Dictionary)

    The substring label for the item or a dictionary of toggle states mapped to sub-label strings, which can be null

    • :enabled(Lang.String)

      The string displayed when the ToggleMenuItem is enabled, or null

    • :disabled(Lang.String)

      The string displayed when the ToggleMenuItem is disabled, or null

Since:

API Level 3.0.0


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