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).
This commit is contained in:
Sander Schobers 2021-05-11 08:25:15 +02:00
parent 72138bb8e3
commit 4cff23cd37

View File

@ -119,6 +119,26 @@ func (s *Slider) Handle(ctx Context, e Event) bool {
if s.ControlBase.Handle(ctx, e) { if s.ControlBase.Handle(ctx, e) {
return true 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 return false
} }