New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Widget scrolling plus #4701
base: develop
Are you sure you want to change the base?
Widget scrolling plus #4701
Changes from all commits
8955049
dc34dad
e572ca8
a09bbd7
0ace386
e332a5e
ea865ab
dc95823
8457816
7a82ec5
9698952
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
github: [fyne-io, andydotxyz, toaster, Jacalz, changkun] | ||
github: [fyne-io, andydotxyz, toaster, Jacalz, changkun, dweymouth, lucor] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,6 +344,14 @@ func (t *Table) TouchCancel(*mobile.TouchEvent) { | |
// Implements: fyne.Focusable | ||
func (t *Table) TypedKey(event *fyne.KeyEvent) { | ||
switch event.Name { | ||
case fyne.KeyHome: | ||
t.ScrollToTop() | ||
case fyne.KeyPageUp: | ||
t.ScrollUpOnePage() | ||
case fyne.KeyPageDown: | ||
t.ScrollDownOnePage() | ||
case fyne.KeyEnd: | ||
t.ScrollToBottom() | ||
case fyne.KeySpace: | ||
t.Select(t.currentFocus) | ||
case fyne.KeyDown: | ||
|
@@ -512,6 +520,7 @@ func (t *Table) ScrollToBottom() { | |
|
||
t.content.Offset.Y = y | ||
t.offset.Y = y | ||
t.content.Refresh() | ||
t.finishScroll() | ||
} | ||
|
||
|
@@ -538,9 +547,38 @@ func (t *Table) ScrollToTop() { | |
|
||
t.content.Offset.Y = 0 | ||
t.offset.Y = 0 | ||
t.content.Refresh() | ||
t.finishScroll() | ||
} | ||
|
||
// scrollByOnePage scrolls down or up by table height | ||
func (t *Table) scrollByOnePage(down bool) { | ||
if t.Length == nil || t.content == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may need to add some offset validation here - please test what happens if you try to keep scrolling when you're already at the top or bottom of the list There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not go out of bounds! There is one bug in the tree widget, but its not introduced with this PR, it just became obvious after implementing it. When you call tree.ScrollToBottom() twice, the last row's top border vanishes. Other than that, there are no problems. Not sure if I should investigate it, since its not part of this PR. I can share some example code (120 lines). |
||
return | ||
} | ||
|
||
height := t.size.Load().Height | ||
if down { | ||
t.content.Offset.Y += height | ||
} else { | ||
t.content.Offset.Y -= height | ||
} | ||
t.offset.Y = t.content.Offset.Y | ||
|
||
t.content.Refresh() | ||
t.finishScroll() | ||
} | ||
|
||
// ScrollUpOnePage scrolls up one page (table height) | ||
func (t *Table) ScrollUpOnePage() { | ||
t.scrollByOnePage(false) | ||
} | ||
|
||
// ScrollDownOnePage scrolls down one page (table height) | ||
func (t *Table) ScrollDownOnePage() { | ||
t.scrollByOnePage(true) | ||
} | ||
|
||
// ScrollToTrailing scrolls horizontally to the trailing edge of the table | ||
// | ||
// Since: 2.1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure these need to be public APIs (you can do the equivalent by
ScrollToOffset(l.GetScrollOffset() + l.Size().Height)
) but if they are going to be new public APIs they need the// Since: 2.5
designation