From b0b34e7791efb1b15cb988716090d1f180d6c7bd Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Thu, 5 Dec 2024 08:20:06 -0800 Subject: [PATCH] add PageUp / PageDown scrolling --- ui/browsing/browsingpane.go | 18 ++++++++++++++---- ui/mainwindow.go | 4 ++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index 105f58b2..8207456d 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -200,14 +200,24 @@ func (b *BrowsingPane) SelectAll() { } func (b *BrowsingPane) ScrollUp() { - if s, ok := b.curPage.(Scrollable); ok { - s.Scroll(-75) - } + b.scrollBy(-75) } func (b *BrowsingPane) ScrollDown() { + b.scrollBy(75) +} + +func (b *BrowsingPane) PageUp() { + b.scrollBy(-b.Size().Height * 0.9) +} + +func (b *BrowsingPane) PageDown() { + b.scrollBy(b.Size().Height * 0.9) +} + +func (b *BrowsingPane) scrollBy(increment float32) { if s, ok := b.curPage.(Scrollable); ok { - s.Scroll(75) + s.Scroll(increment) } } diff --git a/ui/mainwindow.go b/ui/mainwindow.go index 706117a5..ec7fd494 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -383,6 +383,10 @@ func (m *MainWindow) addShortcuts() { m.BrowsingPane.ScrollUp() case fyne.KeyDown: m.BrowsingPane.ScrollDown() + case fyne.KeyPageUp: + m.BrowsingPane.PageUp() + case fyne.KeyPageDown: + m.BrowsingPane.PageDown() case fyne.KeyEscape: m.Controller.CloseEscapablePopUp() case fyne.KeySpace: