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.Symbol, subLabel as Lang.String or Lang.Symbol or { :enabled as Lang.String or Lang.Symbol or Null, :disabled as Lang.String or Lang.Symbol or Null } or Null, identifier, enabled as Lang.Boolean, options as { :alignment as MenuItem.Alignment, :icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol } or Null)

Constructor

Note:

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

Parameters:

  • label(Lang.String, Lang.Symbol)

    The string label for the ToggleMenuItem

  • subLabel(Lang.String, Lang.Symbol, 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, Lang.Symbol)

      The string displayed when the ToggleMenuItem is enabled, or null

    • :disabled(Lang.String, Lang.Symbol)

      The string displayed when the ToggleMenuItem is disabled, or null

  • identifier(Lang.Object)

    The identifier for this ToggleMenuItem, which is typically a String

  • enabled(Lang.Boolean)

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

  • options(Lang.Dictionary)

    A Dictionary of options

    • :alignment(Lang.Number)

      A WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_* constant representing the label alignment, which defaults to the system default for toggle menu items if not specified.

    • :icon(Graphics.BitmapType, WatchUi.Drawable, Lang.Symbol)

      for the subscreen area when the menu item is in focus

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.Symbol or Lang.Dictionary<Lang.Symbol, Lang.String or Lang.Symbol or Null> or Null) as Void

Set a ToggleMenuItem label substring.

Parameters:

  • subLabel(Lang.String, Lang.Symbol, 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 May 31, 2023 8:48:51 AM