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


11989
11990
# File 'Monkeybrains.rb', line 11989

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


11943
11944
# File 'Monkeybrains.rb', line 11943

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


11955
11956
# File 'Monkeybrains.rb', line 11955

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


11967
11968
# File 'Monkeybrains.rb', line 11967

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


12001
12002
# File 'Monkeybrains.rb', line 12001

def onRelease(clickEvent)
end

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

The state of a Selectable has changed.

Parameters:

Returns:

See Also:

Since:

  • 2.1.0


12023
12024
# File 'Monkeybrains.rb', line 12023

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


12012
12013
# File 'Monkeybrains.rb', line 12012

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


11978
11979
# File 'Monkeybrains.rb', line 11978

def onTap(clickEvent)
end