Class: Toybox::WatchUi::Menu

Inherits:
Lang::Object show all

Overview

Note:

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

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.

Examples:

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;
    }
}

See Also:

Since:

  • 1.0.0

Constant Summary

MAX_SIZE = 16

The maximum number of allowed entries in a Menu.

Since:

  • 1.0.0

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Instance Method Details

addItem(name, identifier) ⇒ Object

Add an entry to a Menu.

Parameters:

Since:

  • 1.0.0


14161
14162
# File 'Monkeybrains.rb', line 14161

def addItem(name, identifier)
end

setTitle(title) ⇒ Object

Set a Menu title.

Parameters:

Since:

  • 1.0.0


14152
14153
# File 'Monkeybrains.rb', line 14152

def setTitle(title)
end