From c8d33a0ef4e13d41aa2e5aa0aaec835a0c1195db Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 27 Jul 2024 00:54:40 -0400 Subject: [PATCH] Fix keys for Scrollbar --- scrollbar.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/scrollbar.go b/scrollbar.go index 799ef3e..28f66eb 100644 --- a/scrollbar.go +++ b/scrollbar.go @@ -141,19 +141,15 @@ func (this *Scrollbar) handleKeyUp (key input.Key, numpad bool) bool { switch key { case input.KeyUp, input.KeyLeft: return true case input.KeyDown, input.KeyRight: return true - case input.KeyHome: return true - case input.KeyEnd: return true + case input.KeyPageUp: return true + case input.KeyPageDown: return true + case input.KeyHome: return true + case input.KeyEnd: return true } return false } 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() switch key { @@ -161,15 +157,20 @@ func (this *Scrollbar) handleKeyDown (key input.Key, numpad bool) bool { if modifiers.Alt { this.SetValue(0) } else { - this.SetValue(this.Value() - increment) + this.scrollBy(this.StepSize()) } return true case input.KeyDown, input.KeyRight: if modifiers.Alt { this.SetValue(1) } 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 case input.KeyHome: this.SetValue(0)