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
MENU_ITEM_LABEL_ALIGN_RIGHT 0

API Level 3.0.0

Right align a MenuItem label

MENU_ITEM_LABEL_ALIGN_LEFT 1

API Level 3.0.0

Left align a MenuItem label

Instance Method Summary collapse

Instance Method Details

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

Get the icon

The icon that is used for the subscreen area will be returned If an icon is not been specified, this function will return null

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

The specified icon will be displayed in the subscreen area when this Menu2 item is visible. If an icon is not been specified, the menu2 icon 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 Apr 17, 2024 9:40:39 AM