Class: Toybox::WatchUi::InputDelegate

Inherits:
Lang::Object show all

Overview

InputDelegate handles basic input events.

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.

Examples:

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;
    }
}

See Also:

Since:

  • 1.0.0

Direct Known Subclasses

BehaviorDelegate

Direct Known Subclasses

BehaviorDelegate

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Instance Method Details

onHold(clickEvent) ⇒ Toybox::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:

  • 1.0.0


13336
13337
# File 'Monkeybrains.rb', line 13336

def onHold(clickEvent)
end

onKey(keyEvent) ⇒ Toybox::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:

  • 1.0.0


13290
13291
# File 'Monkeybrains.rb', line 13290

def onKey(keyEvent)
end

onKeyPressed(keyEvent) ⇒ Toybox::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:

  • 1.1.2


13302
13303
# File 'Monkeybrains.rb', line 13302

def onKeyPressed(keyEvent)
end

onKeyReleased(keyEvent) ⇒ Toybox::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:

  • 1.1.2


13314
13315
# File 'Monkeybrains.rb', line 13314

def onKeyReleased(keyEvent)
end

onRelease(clickEvent) ⇒ Toybox::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:

  • 1.0.0


13348
13349
# File 'Monkeybrains.rb', line 13348

def onRelease(clickEvent)
end

onSelectable(selectableEvent) ⇒ Toybox::Lang::Boolean

The state of a Selectable has changed.

Parameters:

Returns:

See Also:

Since:

  • 2.1.0


13370
13371
# File 'Monkeybrains.rb', line 13370

def onSelectable(selectableEvent)
end

onSwipe(swipeEvent) ⇒ Toybox::Lang::Boolean

A touch screen swipe event has occurred.

This is sent when the touch screen is swiped.

Parameters:

Returns:

See Also:

Since:

  • 1.0.0


13359
13360
# File 'Monkeybrains.rb', line 13359

def onSwipe(swipeEvent)
end

onTap(clickEvent) ⇒ Toybox::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:

  • 1.0.0


13325
13326
# File 'Monkeybrains.rb', line 13325

def onTap(clickEvent)
end