From 404b505a41362f340e79374ee3ad4dbd468da3e4 Mon Sep 17 00:00:00 2001 From: cirakg Date: Sun, 25 Oct 2026 13:13:39 +0100 Subject: fix(ui): vertical swipes and drags scroll the list and text screens The Forerunner 70 sends no page behaviour for a swipe on a custom view, so the list and info screens only scrolled with the buttons. Swipes and drags now scroll them directly; one gesture scrolls once even when the device also sends the page behaviour, and a drag's release opens no row. Co-Authored-By: Claude Opus 5.5 --- source/ui/ListDelegate.mc | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'source/ui/ListDelegate.mc') diff --git a/source/ui/ListDelegate.mc b/source/ui/ListDelegate.mc index a7c8bf0..ca7cee9 100644 --- a/source/ui/ListDelegate.mc +++ b/source/ui/ListDelegate.mc @@ -14,14 +14,43 @@ class ListDelegate extends WatchUi.BehaviorDelegate { } function onNextPage() as Boolean { - AppState.activity(); - _view.move(1); + if (!Gesture.recent()) { + AppState.activity(); + _view.move(1); + } return true; } function onPreviousPage() as Boolean { + if (!Gesture.recent()) { + AppState.activity(); + _view.move(-1); + } + return true; + } + + // The Forerunner 70 sends no page behaviour for a vertical swipe, so the + // swipe and the drag scroll here; Gesture makes a gesture count once. + function onSwipe(event as WatchUi.SwipeEvent) as Boolean { + if (!Gesture.isVertical(event)) { + return BehaviorDelegate.onSwipe(event); + } + var step = Gesture.swipeStep(event); + if (step != 0) { + AppState.activity(); + _view.move(step); + } + return true; + } + + // A drag scrolls by the rows it covered, at least one. + function onDrag(event as WatchUi.DragEvent) as Boolean { + var step = Gesture.dragStep(event, _view.rowHeight()); + if (step == 0) { + return false; + } AppState.activity(); - _view.move(-1); + _view.move(step); return true; } @@ -55,6 +84,9 @@ class ListDelegate extends WatchUi.BehaviorDelegate { // A tap opens the row under the finger. function onTap(event as WatchUi.ClickEvent) as Boolean { AppState.activity(); + if (Gesture.tapIgnored()) { + return true; + } var index = _view.rowAt(event.getCoordinates()[1]); if (index < 0) { return true; -- cgit v1.2.3