Class: Toybox::WatchUi::CustomMenu

Inherits:
Menu2 show all

Overview

A representation of a custom menu.

A CustomMenu is a specialized Menu2 View that presents the user with a list of custom rendered options. After an option is selected, the registered onSelect() method will be called.

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

Examples:

Build a CustomMenu programmatically

using Toybox.WatchUi;

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

    function onMenu() {
        var menu = new WatchUi.CustomMenu({itemHeight=>80});
        var delegate;
        menu.addItem(
            new MyCustomMenuItem( // a WatchUi.CustomMenuItem
                :itemOne,
                {}
            )
        );
        menu.addItem(
            new MyCustomMenuItem( // a WatchUi.CustomMenuItem
                :itemTwo,
                {}
            )
        );
        delegate = new MyMenu2Delegate(); // a WatchUi.Menu2InputDelegate
        WatchUi.pushView(menu, delegate, WatchUi.SLIDE_IMMEDIATE);
        return true;
    }
}

See Also:

Since:

  • 3.0.0

Instance Method Summary collapse

Methods inherited from Menu2

deleteItem, findItemById, getItem, setFocus, updateItem

Methods inherited from View

findDrawableById, onHide, onLayout, onShow, onUpdate, setKeyToSelectableInteraction, setLayout

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(itemHeight, backgroundColor, options) ⇒ CustomMenu

Returns a new instance of CustomMenu

Parameters:

Options Hash (options):

Raises:

  • (Toybox::Lang::UnexpectedTypeException)

    Thrown if:

    • The :itemHeight and :backgroundColor are not provided and are not Number objects

    • The :focusItemHeight or :focus options are provided and are not Number objects

    • The :title, :footer, or :foreground options are provided and are not Drawable objects.

Since:

  • 3.0.0


13094
13095
# File 'Monkeybrains.rb', line 13094

def initialize(itemHeight, backgroundColor, options)
end

Instance Method Details

addItem(item) ⇒ Object

Add a CustomMenuItem to a CustomMenu.

Parameters:

Raises:

Since:

  • 3.0.0


13146
13147
# File 'Monkeybrains.rb', line 13146

def addItem(item)
end

drawFooter(dc) ⇒ Object

Draw the CustomMenu footer.

This is called to render the menu footer region.

Parameters:

Since:

  • 3.0.0


13162
13163
# File 'Monkeybrains.rb', line 13162

def drawFooter(dc)
end

drawForeground(dc) ⇒ Object

Draw the CustomMenu foreground.

This is called after a menu's items and title have been rendered. It can be used to draw overlay content for the menu.

Parameters:

Since:

  • 3.0.0


13171
13172
# File 'Monkeybrains.rb', line 13171

def drawForeground(dc)
end

drawTitle(dc) ⇒ Object

Draw the CustomMenu title.

This is called to render the menu title region.

Parameters:

Since:

  • 3.0.0


13154
13155
# File 'Monkeybrains.rb', line 13154

def drawTitle(dc)
end

setBackgroundColor(color) ⇒ Object

Set the background color.

Parameters:

Raises:

Since:

  • 3.0.0


13133
13134
# File 'Monkeybrains.rb', line 13133

def setBackgroundColor(color)
end

setFooter(drawable) ⇒ Object

Set the footer drawable.

Parameters:

Raises:

Since:

  • 3.0.0


13114
13115
# File 'Monkeybrains.rb', line 13114

def setFooter(drawable)
end

setForeground(drawable) ⇒ Object

Set the foreground drawable.

Parameters:

Raises:

Since:

  • 3.0.0


13124
13125
# File 'Monkeybrains.rb', line 13124

def setForeground(drawable)
end

setTitle(drawable) ⇒ Object

Set the title drawable.

Parameters:

Raises:

Since:

  • 3.0.0


13104
13105
# File 'Monkeybrains.rb', line 13104

def setTitle(drawable)
end