Class: Toybox.WatchUi.MenuItem

Inherits:
Toybox.Lang.Object show all

Overview

A representation of a menu item in a Menu2.

A MenuItem is a element of a Menu2 View that represents one of the options in the menu. A MenuItem can be added to a Menu2 using the addItem() method.

See Also:

Since:

API Level 3.0.0

Supported Devices:

Direct Known Subclasses

WatchUi.CheckboxMenuItem, WatchUi.CustomMenuItem, WatchUi.IconMenuItem, WatchUi.ToggleMenuItem

Constant Summary

Alignment

Since:

API Level 3.0.0

Name Value Since Description See Also

Instance Method Summary collapse

Instance Method Details

getIcon() as Graphics.BitmapType or WatchUi.Drawable or Null

Get the icon

Retrieve the icon for this MenuItem.

Supported Devices:

Returns:

Since:

API Level 3.4.0

getId() as Lang.Object or Null

Get a MenuItem identifier.

Returns:

Since:

API Level 3.0.0

getLabel() as Lang.String

Get a MenuItem label.

Returns:

Since:

API Level 3.0.0

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

Get a MenuItem substring label.

Returns:

  • Lang.String

    The substring text label for the MenuItem

Since:

API Level 3.0.0

initialize(label as Lang.String or Lang.ResourceId, subLabel as Lang.String or Lang.ResourceId or Null, identifier as Lang.Object or Null, 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

setIcon(icon as Graphics.BitmapType or WatchUi.Drawable or Lang.ResourceId or Null) as Void

Set the icon

Set the icon displayed in the subscreen area when this MenuItem has the focus. If the provided icon is null, the icon from the Menu2 will be shown instead.

Parameters:

Supported Devices:

Since:

API Level 3.4.0

setLabel(label as Lang.String or Lang.ResourceId) as Void

Set a MenuItem label.

Parameters:

Since:

API Level 3.0.0

Throws:

setSubLabel(subLabel as Lang.String or Lang.ResourceId or Null) as Void

Set a MenuItem substring label.

Parameters:

Since:

API Level 3.0.0

Throws:


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