-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
add OnScroll event to list #5329
base: develop
Are you sure you want to change the base?
Changes from 2 commits
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 |
---|---|---|
|
@@ -37,6 +37,7 @@ type List struct { | |
UpdateItem func(id ListItemID, item fyne.CanvasObject) `json:"-"` | ||
OnSelected func(id ListItemID) `json:"-"` | ||
OnUnselected func(id ListItemID) `json:"-"` | ||
OnFocus func(id ListItemID) `json:"-"` | ||
|
||
// HideSeparators hides the separators between list rows | ||
// | ||
|
@@ -186,6 +187,11 @@ func (l *List) scrollTo(id ListItemID) { | |
l.scroller.Offset.Y = y + lastItemHeight - l.scroller.Size().Height | ||
} | ||
l.offsetUpdated(l.scroller.Offset) | ||
defer func() { | ||
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 will want to call this callback whenever |
||
if f := l.OnFocus; f != nil { | ||
f(id) | ||
} | ||
}() | ||
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. Also, please add some unit tests to verify the behavior, see the existing examples in list_test.go 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. Done! |
||
} | ||
|
||
// Resize is called when this list should change size. We refresh to ensure invisible items are drawn. | ||
|
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.
The naming here should be "OnFocused" to match the convention. Also we will need a comment with a "Since: 2.6" line (see the HideSeparators property for example)