Class: Toybox::WatchUi::BehaviorDelegate

Inherits:
InputDelegate show all

Overview

BehaviorDelegate handles behavior input events.

A BehaviorDelegate differs from an InputDelegate in that it acts upon device-independent behaviors, such as “next page” and “previous page” instead of device-specific button presses. For example, these behaviors might be mapped to swipe left and swipe right inputs on touch screen devices, while on non-touch screen devices these behaviors might be mapped to physical buttons.

Since BehaviorDelegate extends InputDelegate, so it can also act on basic inputs as well. If a BehaviorDelegate returns true for a function (indicating the input was used) then the InputDelegate function that corresponds to the behavior will not be called.

Examples:

using Toybox.System;
using Toybox.WatchUi;

class MyBehaviorDelegate extends BehaviorDelegate {
    // Detect Menu behavior
    function onMenu() {
        System.println("Menu behavior triggered");
        return false; // allow InputDelegate function to be called
    }
    // Detect Menu button input
    function onKey(keyEvent) {
        System.println(keyEvent.getKey()); // e.g. KEY_MENU = 7
        return true;
    }
}

See Also:

  • InputDelegate

Since:

  • 1.0.0

Instance Method Summary collapse

Methods inherited from InputDelegate

onHold, onKey, onKeyPressed, onKeyReleased, onRelease, onSelectable, onSwipe, onTap

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initializeBehaviorDelegate

Returns a new instance of BehaviorDelegate

Since:

  • 1.0.0


12063
12064
# File 'Monkeybrains.rb', line 12063

def initialize()
end

Instance Method Details

onBackToybox::Lang::Boolean

Represents the Back behavior.

This is typically triggered by the back button (KEY_ESC).

Returns:

Since:

  • 1.0.0


12103
12104
# File 'Monkeybrains.rb', line 12103

def onBack()
end

onMenuToybox::Lang::Boolean

Represents the Menu behavior.

This is typically triggered by the menu button (KEY_MENU).

Returns:

Since:

  • 1.0.0


12094
12095
# File 'Monkeybrains.rb', line 12094

def onMenu()
end

onNextModeToybox::Lang::Boolean

Represents the Next behavior.

Returns:

Since:

  • 1.0.0


12109
12110
# File 'Monkeybrains.rb', line 12109

def onNextMode()
end

onNextPageToybox::Lang::Boolean

Represents the Next Page behavior.

This is typically triggered by the down button (KEY_DOWN) or by a SWIPE_UP SwipeEvent on a touch screen.

Returns:

Since:

  • 1.0.0


12074
12075
# File 'Monkeybrains.rb', line 12074

def onNextPage()
end

onPreviousModeToybox::Lang::Boolean

Represents the Previous Mode behavior.

Returns:

Since:

  • 1.0.0


12115
12116
# File 'Monkeybrains.rb', line 12115

def onPreviousMode()
end

onPreviousPageToybox::Lang::Boolean

Represents the Previous Page behavior.

This is typically triggered by the up button (KEY_UP) or by a SWIPE_DOWN SwipeEvent on a touch screen.

Returns:

Since:

  • 1.0.0


12085
12086
# File 'Monkeybrains.rb', line 12085

def onPreviousPage()
end

onSelectToybox::Lang::Boolean

Represents the Selection behavior.

This is typically triggered by the Start/Enter button (KEY_ENTER) or by a CLICK_TYPE_TAP ClickEvent on a touch screen.

Returns:

Since:

  • 1.2.0


12126
12127
# File 'Monkeybrains.rb', line 12126

def onSelect()
end