// Author: cirakg & claude ai // Summary: Input on the list (README 13.4): scroll with UP/DOWN or swipes, open with START or a tap, menu (MENU or long press), back exits. import Toybox.Lang; import Toybox.WatchUi; class ListDelegate extends WatchUi.BehaviorDelegate { private var _view as ListView; function initialize(view as ListView) { BehaviorDelegate.initialize(); _view = view; } function onNextPage() as Boolean { AppState.activity(); _view.move(1); return true; } function onPreviousPage() as Boolean { AppState.activity(); _view.move(-1); return true; } // On touch screens a tap arrives as the select behaviour first; returning // false passes it on to onTap, which opens the row under the finger. The // START button then comes through onKey. function onSelect() as Boolean { if (Ui.isTouch()) { return false; } openFocused(); return true; } function onKey(event as WatchUi.KeyEvent) as Boolean { if (Ui.isTouch() && event.getKey() == WatchUi.KEY_ENTER) { openFocused(); return true; } return false; } private function openFocused() as Void { AppState.activity(); var id = _view.focusedId(); if (id != null) { Nav.openEntry(id); } } // A tap opens the row under the finger. function onTap(event as WatchUi.ClickEvent) as Boolean { AppState.activity(); var index = _view.rowAt(event.getCoordinates()[1]); if (index < 0) { return true; } _view.focus = index; var id = _view.focusedId(); if (id != null) { Nav.openEntry(id); } return true; } // A long press opens the menu too: watches without a MENU button // (Venu X1) have no other way to reach it (README 13.4). function onHold(event as WatchUi.ClickEvent) as Boolean { AppState.activity(); Nav.openMenu(); return true; } function onMenu() as Boolean { AppState.activity(); Nav.openMenu(); return true; } // BACK leaves the app; onStop locks everything. function onBack() as Boolean { return false; } }