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


12003
12004
# File 'Monkeybrains.rb', line 12003

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


11957
11958
# File 'Monkeybrains.rb', line 11957

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


11969
11970
# File 'Monkeybrains.rb', line 11969

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


11981
11982
# File 'Monkeybrains.rb', line 11981

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


12015
12016
# File 'Monkeybrains.rb', line 12015

def onRelease(clickEvent)
end

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

The state of a Selectable has changed.

Parameters:

Returns:

See Also:

Since:

  • 2.1.0


12037
12038
# File 'Monkeybrains.rb', line 12037

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


12026
12027
# File 'Monkeybrains.rb', line 12026

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


11992
11993
# File 'Monkeybrains.rb', line 11992

def onTap(clickEvent)
end