Class: Toybox.WatchUi.Menu2
- Inherits:
-
Toybox.WatchUi.View
Overview
A representation of an on-screen menu. A Menu2 is a special View, similar to a Toybox::WatchUi::Menu, that presents the user with a list of options. A Menu2 offers more capabilities than a Toybox::WatchUi::Menu, like graphical titles, menu items that can be updated dynamically, and additional menu elements such as check boxes.
After an option is selected, the registered onSelect() method will be called. While a Menu2 can be generated programmatically, they should generally be created as a resource.
A Menu2 is pushed using pushView(), which provides a Menu2InputDelegate as the input delegate.
See Also:
The look and feel of a Menu2 is device-specific.
Direct Known Subclasses
WatchUi.CheckboxMenu, WatchUi.CustomMenu
Constant Summary
-
DividerType
Divider type for supported devices
Name | Value | Since | Description | See Also |
---|---|---|---|---|
DIVIDER_TYPE_DEFAULT | 0 | API Level 5.0.1 |
Default divider type |
|
DIVIDER_TYPE_ICON | 1 | API Level 5.0.1 |
Icon divider type |
Instance Method Summary collapse
-
addItem(item as WatchUi.MenuItem) as Void
Add a MenuItem to a Menu2.
-
deleteItem(index as Lang.Number) as Lang.Boolean or Null
Delete a MenuItem from a Menu2.
-
findItemById(identifier as Lang.Object) as Lang.Number
Find a MenuItem by ID in a Menu2.
-
getIcon() as Graphics.BitmapType or WatchUi.Drawable or Null
Get the icon Retrieve the icon for this Menu2.
-
getItem(index as Lang.Number) as WatchUi.MenuItem or Null
Get a MenuItem from a Menu2.
-
initialize(options as { :title as Lang.String or Lang.ResourceId or WatchUi.Drawable, :focus as Lang.Number, :icon as Graphics.BitmapType or WatchUi.Drawable or Lang.ResourceId, :theme as WatchUi.MenuTheme or Null, :dividerType as Menu2.DividerType or Null } or Null)
Constructor.
-
setDividerType(divider as Menu2.DividerType or Null) as Void
Set or change the desired divider type.
-
setFocus(focus as Lang.Number or Null) as Void
Set the focus of a MenuItem in a Menu2.
-
setIcon(icon as Graphics.BitmapType or WatchUi.Drawable or Lang.ResourceId or Null) as Void
Set the icon Set the icon to display in the subscreen area when the focused MenuItem does not have an icon.
-
setTheme(theme as WatchUi.MenuTheme or Null) as Void
Set the theme.
-
setTitle(title as Lang.String or Lang.ResourceId or WatchUi.Drawable or Null) as Void
Set a Menu2 title.
-
updateItem(item as WatchUi.MenuItem, index as Lang.Number) as Void
Update a MenuItem in a Menu2.
Instance Method Details
addItem(item as WatchUi.MenuItem) as Void
Add a MenuItem to a Menu2.
deleteItem(index as Lang.Number) as Lang.Boolean or Null
Delete a MenuItem from a Menu2.
findItemById(identifier as Lang.Object) as Lang.Number
Find a MenuItem by ID in a Menu2.
getIcon() as Graphics.BitmapType or WatchUi.Drawable or Null
Get the icon
Retrieve the icon for this Menu2.
getItem(index as Lang.Number) as WatchUi.MenuItem or Null
Get a MenuItem from a Menu2.
initialize(options as { :title as Lang.String or Lang.ResourceId or WatchUi.Drawable, :focus as Lang.Number, :icon as Graphics.BitmapType or WatchUi.Drawable or Lang.ResourceId, :theme as WatchUi.MenuTheme or Null, :dividerType as Menu2.DividerType or Null } or Null)
Constructor
The :icon
option is only used on ConnectIQ 3.4.0 devices with subscreen support.
The :theme
option is only used on ConnectIQ 4.1.8 devices with menu theme support.
The :dividerType
option is only used on ConnectIQ 5.0.1 devices with divider support.
setDividerType(divider as Menu2.DividerType or Null) as Void
Set or change the desired divider type.
If set to Menu2.DIVIDER_TYPE_ICON.
For IconMenuItem and
CheckboxMenuItem, icon and checkbox
will be rendered on the left side of the divider if item is
MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT
or default
aligned.
For ToggleMenuItem, toggle icon will be rendered on the left side of the divider, if item is MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT aligned only.
Menu2.DIVIDER_TYPE_DEFAULT will be used
if not set for devices that support divider, or null
is passed.
setFocus(focus as Lang.Number or Null) as Void
Set the focus of a MenuItem in a Menu2.
setIcon(icon as Graphics.BitmapType or WatchUi.Drawable or Lang.ResourceId or Null) as Void
Set the icon
Set the icon to display in the subscreen area when the focused MenuItem does not have an icon. If this menu does not have an icon, the app icon will be shown instead.
setTheme(theme as WatchUi.MenuTheme or Null) as Void
Set the theme
setTitle(title as Lang.String or Lang.ResourceId or WatchUi.Drawable or Null) as Void
Set a Menu2 title.
updateItem(item as WatchUi.MenuItem, index as Lang.Number) as Void
Update a MenuItem in a Menu2.