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



11515
11516
# File 'Monkeybrains.rb', line 11515

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



11555
11556
# File 'Monkeybrains.rb', line 11555

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



11546
11547
# File 'Monkeybrains.rb', line 11546

def onMenu()
end

onNextModeToybox::Lang::Boolean

Represents the Next behavior.

Returns:

Since:

  • 1.0.0



11561
11562
# File 'Monkeybrains.rb', line 11561

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



11526
11527
# File 'Monkeybrains.rb', line 11526

def onNextPage()
end

onPreviousModeToybox::Lang::Boolean

Represents the Previous Mode behavior.

Returns:

Since:

  • 1.0.0



11567
11568
# File 'Monkeybrains.rb', line 11567

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



11537
11538
# File 'Monkeybrains.rb', line 11537

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



11578
11579
# File 'Monkeybrains.rb', line 11578

def onSelect()
end