Class: Toybox.WatchUi.Menu

Inherits:
Toybox.Lang.Object show all

Overview

A representation of an on-screen menu.

A Menu is a special View that presents the user with a list of options. After an option is selected, the registered onMenuItem() method will be called. While a Menu can be generated programmatically, they should generally be created as a resource.

A Menu is pushed using pushView(), which provides a MenuInputDelegate as the input delegate.

See Also:

Note:

The look and feel of a menu is device-specific.

Example:

Build a simple menu programmatically

using Toybox.WatchUi;

class MyBehaviorDelegate extends WatchUi.BehaviorDelegate {
    function initialize() {
        BehaviorDelegate.initialize();
    }

    function onMenu() {
        var menu = new WatchUi.Menu();
        var delegate;
        menu.setTitle("My Menu");
        menu.addItem("Item One", :one);
        menu.addItem("Item Two", :two);
        delegate = new MyMenuDelegate(); // a WatchUi.MenuInputDelegate
        WatchUi.pushView(menu, delegate, WatchUi.SLIDE_IMMEDIATE);
        return true;
    }
}

Since:

API Level 1.0.0

Constant Summary

Constant Variables

Type Name Value Since Description
Type MAX_SIZE 16

API Level 1.0.0

The maximum number of allowed entries in a Menu.

Instance Method Summary collapse

Instance Method Details

addItem(label as Lang.String or Lang.ResourceId, identifier as Lang.Symbol) as Void

Add an entry to a Menu.

Parameters:

Since:

API Level 1.0.0

setTitle(title as Lang.String or Lang.ResourceId) as Void

Set a Menu title.

Parameters:

Since:

API Level 1.0.0


Generated Apr 17, 2024 9:40:39 AM