Class: Toybox::WatchUi::Menu2

Inherits:
View show all

Overview

Note:

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

A representation of an on-screen menu. A Menu2 is a special View, similar to a Menu, that presents the user with a list of options. A Menu2 offers more capabilities than a 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.

Examples:

Build a simple Menu2 programmatically

using Toybox.WatchUi;

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

    function onMenu() {
        var menu = new WatchUi.Menu2({:title=>"My Menu2"});
        var delegate;
        menu.addItem(
            new MenuItem(
                "Item 1 Label",
                "Item 1 subLabel",
                "itemOneId",
                {}
            )
        );
        menu.addItem(
            new MenuItem(
                "Item 2 Label",
                "Item 2 subLabel",
                "itemTwoId",
                {}
            )
        );
        delegate = new MyMenu2Delegate(); // a WatchUi.Menu2InputDelegate
        WatchUi.pushView(menu, delegate, WatchUi.SLIDE_IMMEDIATE);
        return true;
    }
}

See Also:

Since:

  • 3.0.0

Direct Known Subclasses

CheckboxMenu, CustomMenu

Direct Known Subclasses

CheckboxMenu, CustomMenu

Instance Method Summary collapse

Methods inherited from View

addLayer, clearLayers, findDrawableById, getLayerIndex, getLayers, insertLayer, onHide, onLayout, onShow, onUpdate, removeLayer, setKeyToSelectableInteraction, setLayout

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(options) ⇒ Menu2

Returns a new instance of Menu2

Parameters:

Options Hash (options):

Since:

  • 3.0.0


14288
14289
# File 'Monkeybrains.rb', line 14288

def initialize(options)
end

Instance Method Details

addItem(item) ⇒ Object

Add a MenuItem to a Menu2.

Parameters:

Since:

  • 3.0.0


14312
14313
# File 'Monkeybrains.rb', line 14312

def addItem(item)
end

deleteItem(index) ⇒ Object

Delete a MenuItem from a Menu2.

Parameters:

Since:

  • 3.0.0


14320
14321
# File 'Monkeybrains.rb', line 14320

def deleteItem(index)
end

findItemById(identifier) ⇒ Toybox::Lang::Number

Find a MenuItem by ID in a Menu2.

Parameters:

Returns:

Since:

  • 3.0.0


14345
14346
# File 'Monkeybrains.rb', line 14345

def findItemById(identifier)
end

getItem(index) ⇒ Toybox::WatchUi::MenuItem

Get a MenuItem from a Menu2.

Parameters:

Returns:

Since:

  • 3.0.0


14328
14329
# File 'Monkeybrains.rb', line 14328

def getItem(index)
end

setFocus(focus) ⇒ Object

Set the focus of a MenuItem in a Menu2.

Parameters:

Since:

  • 3.0.0


14304
14305
# File 'Monkeybrains.rb', line 14304

def setFocus(focus)
end

setTitle(title) ⇒ Object

Set a Menu2 title.

Parameters:

Since:

  • 3.0.0


14296
14297
# File 'Monkeybrains.rb', line 14296

def setTitle(title)
end

updateItem(item, index) ⇒ Object

Update a MenuItem in a Menu2.

Parameters:

Since:

  • 3.0.0


14335
14336
# File 'Monkeybrains.rb', line 14335

def updateItem(item, index)
end