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

findDrawableById, onHide, onLayout, onShow, onUpdate, 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


12887
12888
# File 'Monkeybrains.rb', line 12887

def initialize(options)
end

Instance Method Details

addItem(item) ⇒ Object

Add a MenuItem to a Menu2.

Parameters:

Since:

  • 3.0.0


12911
12912
# File 'Monkeybrains.rb', line 12911

def addItem(item)
end

deleteItem(index) ⇒ Object

Delete a MenuItem from a Menu2.

Parameters:

Since:

  • 3.0.0


12919
12920
# File 'Monkeybrains.rb', line 12919

def deleteItem(index)
end

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

Find a MenuItem by ID in a Menu2.

Parameters:

Returns:

Since:

  • 3.0.0


12944
12945
# File 'Monkeybrains.rb', line 12944

def findItemById(identifier)
end

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

Get a MenuItem from a Menu2.

Parameters:

Returns:

Since:

  • 3.0.0


12927
12928
# File 'Monkeybrains.rb', line 12927

def getItem(index)
end

setFocus(focus) ⇒ Object

Set the focus of a MenuItem in a Menu2.

Parameters:

Since:

  • 3.0.0


12903
12904
# File 'Monkeybrains.rb', line 12903

def setFocus(focus)
end

setTitle(title) ⇒ Object

Set a Menu2 title.

Parameters:

Since:

  • 3.0.0


12895
12896
# File 'Monkeybrains.rb', line 12895

def setTitle(title)
end

updateItem(item, index) ⇒ Object

Update a MenuItem in a Menu2.

Parameters:

Since:

  • 3.0.0


12934
12935
# File 'Monkeybrains.rb', line 12934

def updateItem(item, index)
end