Fix keys for Scrollbar

This commit is contained in:
Sasha Koshka 2024-07-27 00:54:40 -04:00
parent 9fa764c7b9
commit c8d33a0ef4

View File

@ -141,6 +141,8 @@ func (this *Scrollbar) handleKeyUp (key input.Key, numpad bool) bool {
switch key { switch key {
case input.KeyUp, input.KeyLeft: return true case input.KeyUp, input.KeyLeft: return true
case input.KeyDown, input.KeyRight: return true case input.KeyDown, input.KeyRight: return true
case input.KeyPageUp: return true
case input.KeyPageDown: return true
case input.KeyHome: return true case input.KeyHome: return true
case input.KeyEnd: return true case input.KeyEnd: return true
} }
@ -148,12 +150,6 @@ func (this *Scrollbar) handleKeyUp (key input.Key, numpad bool) bool {
} }
func (this *Scrollbar) handleKeyDown (key input.Key, numpad bool) bool { func (this *Scrollbar) handleKeyDown (key input.Key, numpad bool) bool {
var increment float64; if this.layout.vertical {
increment = -0.05
} else {
increment = 0.05
}
modifiers := this.Window().Modifiers() modifiers := this.Window().Modifiers()
switch key { switch key {
@ -161,15 +157,20 @@ func (this *Scrollbar) handleKeyDown (key input.Key, numpad bool) bool {
if modifiers.Alt { if modifiers.Alt {
this.SetValue(0) this.SetValue(0)
} else { } else {
this.SetValue(this.Value() - increment) this.scrollBy(this.StepSize())
} }
return true return true
case input.KeyDown, input.KeyRight: case input.KeyDown, input.KeyRight:
if modifiers.Alt { if modifiers.Alt {
this.SetValue(1) this.SetValue(1)
} else { } else {
this.SetValue(this.Value() + increment) this.scrollBy(-this.StepSize())
} }
case input.KeyPageUp:
this.scrollBy(this.PageSize())
return true
case input.KeyPageDown:
this.scrollBy(-this.PageSize())
return true return true
case input.KeyHome: case input.KeyHome:
this.SetValue(0) this.SetValue(0)