Class: Toybox.WatchUi.InputDelegate

Overview

InputDelegate handles basic input events.

Note that on wearable products, input events are not supported for data fields.

There are four types of basic inputs InputDelegate can handle:

This class is the base class for BehaviorDelegate, which goes beyond simple key and screen-based input.

See Also:

Example:

using Toybox.System;
using Toybox.WatchUi;

class MyInputDelegate extends WatchUi.InputDelegate {
    function onKey(keyEvent) {
        System.println(keyEvent.getKey());         // e.g. KEY_MENU = 7
        return true;
    }

    function onTap(clickEvent) {
        System.println(clickEvent.getType());      // e.g. CLICK_TYPE_TAP = 0
        return true;
    }

    function onSwipe(swipeEvent) {
        System.println(swipeEvent.getDirection()); // e.g. SWIPE_DOWN = 2
        return true;
    }
}

Since:

API Level 1.0.0

Direct Known Subclasses

WatchUi.BehaviorDelegate

Instance Method Summary collapse

Instance Method Details

onDrag(dragEvent as WatchUi.DragEvent) as Lang.Boolean

A touch screen drag event has occurred.

This is sent when the touch screen is dragged.

Parameters:

Supported Devices:

Returns:

See Also:

Since:

API Level 3.3.0

onFlick(flickEvent as WatchUi.FlickEvent) as Lang.Boolean

A touch screen flick event has occurred.

This is sent when the touch screen is flicked.

Parameters:

Supported Devices:

Returns:

See Also:

Since:

API Level 3.3.0

onHold(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

A touch screen hold event has occurred.

This is sent when the touch screen is touched and not released.

Parameters:

Returns:

See Also:

Since:

API Level 1.0.0

onKey(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

A physical button has been pressed and released.

To find out which key was pressed, use KeyEvent.getKey() to get the button's WatchUi.KEY_* enum value.

Parameters:

Returns:

See Also:

Since:

API Level 1.0.0

onKeyPressed(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

A physical button has been pressed down.

To find out which key was pressed, use KeyEvent.getKey() to get the button's WatchUi.KEY_* enum value.

Parameters:

Returns:

See Also:

Since:

API Level 1.1.2

onKeyReleased(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

A physical button has been released.

To find out which key was pressed, use KeyEvent.getKey() to get the button's WatchUi.KEY_* enum value.

Parameters:

Returns:

See Also:

Since:

API Level 1.1.2

onRelease(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

A touch screen release event has occurred.

This is only sent after an onHold() event, once the hold on the touch screen is released.

Parameters:

Returns:

See Also:

Since:

API Level 1.0.0

onSelectable(selectableEvent as WatchUi.SelectableEvent) as Lang.Boolean

The state of a Selectable has changed.

Parameters:

  • selectableEvent(WatchUi.SelectableEvent)

    The selectable event containing the information about the Selectable whose state has changed

Returns:

See Also:

Since:

API Level 2.1.0

onSwipe(swipeEvent as WatchUi.SwipeEvent) as Lang.Boolean

A touch screen swipe event has occurred.

This is sent when the touch screen is swiped.

Parameters:

Returns:

See Also:

Since:

API Level 1.0.0

onTap(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

A screen tap event has occurred.

This is sent when the touch screen is tapped (a quick touch and release).

Parameters:

Returns:

See Also:

Since:

API Level 1.0.0


Generated Jun 6, 2024 10:31:54 AM