Class: Toybox::WatchUi::TextPicker

Inherits:
Lang::Object show all

Overview

Note:

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

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.

Examples:

using Toybox.WatchUi;

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

class MyTextPickerDelegate extends WatchUi.TextPickerDelegate {

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

    function onTextEntered(text, changed) {
        screenMessage = text + "\n" + "Changed: " + changed;
        lastText = text;
    }

    function onCancel() {
        screenMessage = "Canceled";
    }
}

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

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

See Also:

Since:

  • 1.1.0

Supported Devices:

  • All devices except Approach S60 / vivoactive / vivoactive HR / Edge 130

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(initialText) ⇒ TextPicker

Returns a new instance of TextPicker

Parameters:

Since:

  • 1.1.0


13887
13888
# File 'Monkeybrains.rb', line 13887

def initialize(initialText)
end