Tap-to-rotate: tap icon to select, tap selected to open

Tapping an unselected icon in the menu ring rotates to it with
animation. Tapping the already-selected icon opens it. Icon
positions are tracked from last render for hit detection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
EiSiMo 2026-04-13 19:35:35 +02:00
parent bcac9cbaa4
commit a45f1b5215
2 changed files with 61 additions and 3 deletions

View file

@ -1,9 +1,9 @@
import Toybox.Lang;
import Toybox.WatchUi;
// Routes menu input. UP/DOWN rotate the ring. START/STOP dispatches:
// - event types (arrest, start, ) push the GPS LoadingView
// - history / delete are stubbed until later phases
// Routes menu input. UP/DOWN rotate the ring. START/STOP opens
// the selected item. Tap on an icon rotates to it; tap on the
// already-selected icon opens it.
class MenuDelegate extends WatchUi.BehaviorDelegate {
private var _view as MenuView;
@ -23,7 +23,27 @@ class MenuDelegate extends WatchUi.BehaviorDelegate {
return true;
}
function onTap(evt as WatchUi.ClickEvent) as Boolean {
var coords = evt.getCoordinates();
var tapX = coords[0] as Number;
var tapY = coords[1] as Number;
var idx = _view.itemIndexAt(tapX, tapY);
if (idx < 0) { return false; }
if (idx == _view.selectedIndex()) {
// Tap on already-selected item open it.
return _openSelected();
}
// Tap on another item rotate to it.
_view.rotateTo(idx);
return true;
}
function onSelect() as Boolean {
return _openSelected();
}
private function _openSelected() as Boolean {
var item = _view.selectedItem();
var key = item[:key] as String;