Class: Toybox.WatchUi.TextPicker

Overview

A representation of an on-screen text picker.

A TextPicker is a special View that provides a way to specify textual input in an app. A TextPicker is pushed using pushView(), and provides a TextPickerDelegate as the input delegate. A default value can be provided and is displayed as editable text with the cursor placed at the end.

See Also:

Note:

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

Example:

import Toybox.WatchUi;
import Toybox.Lang;

// A string to display on the screen
var screenMessage as String = "Press Menu to Enter Text";
var lastText as String = "";

class MyTextPickerDelegate extends TextPickerDelegate {

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

    function onTextEntered(text as String, changed as Boolean) as Boolean {
        screenMessage = text + "\n" + "Changed: " + changed;
        lastText = text;
        return true;
    }

    function onCancel() as Boolean {
        screenMessage = "Canceled";
        return true;
    }
}

class MyInputDelegate extends InputDelegate {
    function initialize() {
        InputDelegate.initialize();
    }

    function onKey(key as WatchUi.KeyEvent) as Boolean {
        if (WatchUi has :TextPicker) {
            if (key.getKey() == WatchUi.KEY_MENU) {
                WatchUi.pushView(
                    new WatchUi.TextPicker(lastText),
                    new MyTextPickerDelegate(),
                    WatchUi.SLIDE_DOWN
                );
            }
        }
        return true;
    }
}

Since:

API Level 1.1.0

App Types and Runtime Contexts:

  • Audio Content Provider

  • Data Field

  • Glance

  • Watch App

  • Watch Face

  • Widget

Supported Devices:

Instance Method Summary collapse

Instance Method Details

initialize(initialText as Lang.String)

Constructor

Parameters:

  • initialText — (Lang.String) —

    The initial text for the TextPicker

Since:

API Level 1.1.0


Generated Oct 19, 2026, 4:16:40 PM