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


14261
14262
# File 'Monkeybrains.rb', line 14261

def initialize(options)
end

Instance Method Details

addItem(item) ⇒ Object

Add a MenuItem to a Menu2.

Parameters:

Since:

  • 3.0.0


14285
14286
# File 'Monkeybrains.rb', line 14285

def addItem(item)
end

deleteItem(index) ⇒ Object

Delete a MenuItem from a Menu2.

Parameters:

Since:

  • 3.0.0


14293
14294
# File 'Monkeybrains.rb', line 14293

def deleteItem(index)
end

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

Find a MenuItem by ID in a Menu2.

Parameters:

Returns:

Since:

  • 3.0.0


14318
14319
# File 'Monkeybrains.rb', line 14318

def findItemById(identifier)
end

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

Get a MenuItem from a Menu2.

Parameters:

Returns:

Since:

  • 3.0.0


14301
14302
# File 'Monkeybrains.rb', line 14301

def getItem(index)
end

setFocus(focus) ⇒ Object

Set the focus of a MenuItem in a Menu2.

Parameters:

Since:

  • 3.0.0


14277
14278
# File 'Monkeybrains.rb', line 14277

def setFocus(focus)
end

setTitle(title) ⇒ Object

Set a Menu2 title.

Parameters:

Since:

  • 3.0.0


14269
14270
# File 'Monkeybrains.rb', line 14269

def setTitle(title)
end

updateItem(item, index) ⇒ Object

Update a MenuItem in a Menu2.

Parameters:

Since:

  • 3.0.0


14308
14309
# File 'Monkeybrains.rb', line 14308

def updateItem(item, index)
end