Class: Toybox.WatchUi.CheckboxMenu

Overview

A representation of a check box menu.

A CheckboxMenu is a specialized Menu2 View that presents the user with a list of check box options. After an option is selected, the registered onSelect() method will be called. While a CheckboxMenu can be generated programmatically, they should generally be created as a resource.

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

See Also:

Note:

The look and feel of a CheckboxMenu is device-specific.

Example:

Build a simple CheckboxMenu programmatically

using Toybox.WatchUi;

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

    function onMenu() {
        var menu = new WatchUi.CheckboxMenu({:title=>"My CheckboxMenu"});
        var delegate;
        menu.addItem(
            new CheckboxMenuItem(
                "Item 1 Label",
                "Item 1 subLabel",
                "itemOneId",
                true,
                {}
            )
        );
        menu.addItem(
            new CheckboxMenuItem(
                "Item 2 Label",
                "Item 2 subLabel",
                "itemTwoId",
                false,
                {}
            )
        );
        delegate = new MyMenu2Delegate(); // a WatchUi.Menu2InputDelegate
        WatchUi.pushView(menu, delegate, WatchUi.SLIDE_IMMEDIATE);
        return true;
    }
}

Since:

API Level 3.0.0

Supported Devices:

Instance Method Summary collapse

Instance Method Details

addItem(item as WatchUi.CheckboxMenuItem) as Void

Add a CheckboxMenuItem to a CheckboxMenu.

Parameters:

Since:

API Level 3.0.0

Throws:

initialize(options as { :title as Lang.String or Lang.ResourceId or WatchUi.Drawable, :focus as Lang.Number, :icon as Graphics.BitmapType or Lang.ResourceId or WatchUi.Drawable, :theme as WatchUi.MenuTheme or Null, :dividerType as Menu2.DividerType or Null } or Null)

Constructor

Note:

The :icon option is only used on ConnectIQ 3.4.0 devices with subscreen support.

Note:

The :theme option is only used on ConnectIQ 4.1.8 devices with menu theme support.

Note:

The :dividerType option is only used on ConnectIQ 5.0.1 devices with divider support.

Parameters:

See Also:

Since:

API Level 3.0.0


Generated Sep 23, 2024, 3:32:49 PM