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


14468
14469
# File 'Monkeybrains.rb', line 14468

def initialize(itemHeight, backgroundColor, options)
end

Instance Method Details

addItem(item) ⇒ Object

Add a CustomMenuItem to a CustomMenu.

Parameters:

Raises:

Since:

  • 3.0.0


14520
14521
# File 'Monkeybrains.rb', line 14520

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


14536
14537
# File 'Monkeybrains.rb', line 14536

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


14545
14546
# File 'Monkeybrains.rb', line 14545

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


14528
14529
# File 'Monkeybrains.rb', line 14528

def drawTitle(dc)
end

setBackgroundColor(color) ⇒ Object

Set the background color.

Parameters:

Raises:

Since:

  • 3.0.0


14507
14508
# File 'Monkeybrains.rb', line 14507

def setBackgroundColor(color)
end

setFooter(drawable) ⇒ Object

Set the footer drawable.

Parameters:

Raises:

Since:

  • 3.0.0


14488
14489
# File 'Monkeybrains.rb', line 14488

def setFooter(drawable)
end

setForeground(drawable) ⇒ Object

Set the foreground drawable.

Parameters:

Raises:

Since:

  • 3.0.0


14498
14499
# File 'Monkeybrains.rb', line 14498

def setForeground(drawable)
end

setTitle(drawable) ⇒ Object

Set the title drawable.

Parameters:

Raises:

Since:

  • 3.0.0


14478
14479
# File 'Monkeybrains.rb', line 14478

def setTitle(drawable)
end