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

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(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


14495
14496
# File 'Monkeybrains.rb', line 14495

def initialize(itemHeight, backgroundColor, options)
end

Instance Method Details

addItem(item) ⇒ Object

Add a CustomMenuItem to a CustomMenu.

Parameters:

Raises:

Since:

  • 3.0.0


14547
14548
# File 'Monkeybrains.rb', line 14547

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


14563
14564
# File 'Monkeybrains.rb', line 14563

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


14572
14573
# File 'Monkeybrains.rb', line 14572

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


14555
14556
# File 'Monkeybrains.rb', line 14555

def drawTitle(dc)
end

setBackgroundColor(color) ⇒ Object

Set the background color.

Parameters:

Raises:

Since:

  • 3.0.0


14534
14535
# File 'Monkeybrains.rb', line 14534

def setBackgroundColor(color)
end

setFooter(drawable) ⇒ Object

Set the footer drawable.

Parameters:

Raises:

Since:

  • 3.0.0


14515
14516
# File 'Monkeybrains.rb', line 14515

def setFooter(drawable)
end

setForeground(drawable) ⇒ Object

Set the foreground drawable.

Parameters:

Raises:

Since:

  • 3.0.0


14525
14526
# File 'Monkeybrains.rb', line 14525

def setForeground(drawable)
end

setTitle(drawable) ⇒ Object

Set the title drawable.

Parameters:

Raises:

Since:

  • 3.0.0


14505
14506
# File 'Monkeybrains.rb', line 14505

def setTitle(drawable)
end