From 172fbaeb2af4022bd0b24e4adf1f1f4151224449 Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Tue, 8 Jul 2025 22:10:54 +0300 Subject: [PATCH] feat(tracker/gioui): make switches left&right clickable when active --- tracker/gioui/param.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tracker/gioui/param.go b/tracker/gioui/param.go index e8ea94d..3e3b1b9 100644 --- a/tracker/gioui/param.go +++ b/tracker/gioui/param.go @@ -337,6 +337,30 @@ func Switch(v tracker.Parameter, th *Theme, state *ParamState, hint string, scro func (s *SwitchWidget) Layout(gtx C) D { s.State.update(gtx, s.Value, s.Scroll) + for s.Scroll { + ev, ok := gtx.Event(pointer.Filter{Target: s.State, Kinds: pointer.Press}) + if !ok { + break + } + if pe, ok := ev.(pointer.Event); ok && pe.Kind == pointer.Press { + curVal := s.Value.Value() + if pe.Buttons == pointer.ButtonPrimary { + if curVal >= 1 { + s.Value.SetValue(0) + } else { + s.Value.SetValue(curVal + 1) + } + } + if pe.Buttons == pointer.ButtonSecondary { + if curVal <= -1 { + s.Value.SetValue(0) + } else { + s.Value.SetValue(curVal - 1) + } + } + s.State.tipArea.Appear(gtx.Now) + } + } width := gtx.Dp(s.Style.Width) height := gtx.Dp(s.Style.Height) var fg, bg color.NRGBA