Class: Toybox.WatchUi.NumberPicker

Overview

A representation of an on-screen number picker.

A NumberPicker is a special View that provides a way to specify numeric values within an app. A NumberPicker is pushed using pushView() and provides a NumberPickerDelegate as the input delegate.

The NumberPicker class is limited to the eight specific modes described by the WatchUi.NUMBER_PICKER_* types enum. There are set minimum and maximum values enforced by the product for each mode, and the initial value of the NumberPicker will be adjusted to fall within these bounds.

This has been deprecated

This class may be removed after System 3.

See Also:

Note:

The look and feel of a number picker is device-specific.

Example:

Display a distance picker when the Menu button is pressed

using Toybox.WatchUi;

class MyNumberPickerDelegate extends WatchUi.NumberPickerDelegate {
    function initialize() {
        NumberPickerDelegate.initialize();
    }

    function onNumberPicked(value) {
        myValue = value; // e.g. 1000f
    }
}

class MyInputDelegate extends WatchUi.BehaviorDelegate {
    var myPicker;

    function initialize() {
        BehaviorDelegate.initialize();
    }

    function onMenu() {
        if (WatchUi has :NumberPicker) {
            myPicker = new WatchUi.NumberPicker(
                WatchUi.NUMBER_PICKER_DISTANCE,
                myValue
            );
            WatchUi.pushView(
                myPicker,
                new MyNumberPickerDelegate(),
                WatchUi.SLIDE_IMMEDIATE
            );
        }
        return true;
    }
}

Since:

API Level 1.0.0

Supported Devices:

Instance Method Summary collapse

Instance Method Details

initialize(mode as WatchUi.NumberPickerMode, initialValue as Lang.Number or Lang.Float or Time.Duration)

Constructor

Parameters:

  • mode(Lang Number)

    The NUMBER_PICKER_* value for the desired mode

  • initialValue(Lang.Number, Lang.Float, Time.Duration)

    The initial value for the NumberPicker, dependent on the specified mode

Since:

API Level 1.0.0


Generated Jan 5, 2024 1:53:16 PM