From 4cff23cd37521fbee71534845a6c8503f96d0c64 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Tue, 11 May 2021 08:25:15 +0200 Subject: [PATCH] Mouse wheel now increments/decrements the slider value by 1. - With shift pressed it moves the value 10. - With control pressed it moves the value with 0.1 (does nothing when the Integer flag is enabled). --- ui/slider.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/slider.go b/ui/slider.go index f180a68..68c9d33 100644 --- a/ui/slider.go +++ b/ui/slider.go @@ -119,6 +119,26 @@ func (s *Slider) Handle(ctx Context, e Event) bool { if s.ControlBase.Handle(ctx, e) { return true } + if !s.IsOver() { + return false + } + switch e := e.(type) { + case *MouseMoveEvent: + if e.MouseWheel != 0 { + var speed float32 = 1 + mods := ctx.KeyModifiers() + if mods&KeyModifierShift == KeyModifierShift { + speed = 10 + } else if mods&KeyModifierControl == KeyModifierControl { + speed = 0.1 + } + if e.MouseWheel > 0 { + s.setValue(s.Value + speed) + } else { + s.setValue(s.Value - speed) + } + } + } return false }