Skip to content
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 multi-select for list #4477

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

dweymouth
Copy link
Contributor

@dweymouth dweymouth commented Dec 22, 2023

Description:

  • Adds new enum widget.SelectionMode (values: SelectionSingle, SelectionMultiple, SelectionNone)
    • This only effects the tap/key handling, not the programmatic APIs
  • Adds tap/key handling for multi-select, respecting SelectionMode setting
  • Adds a few new APIs related to multi-select
    • SelectOnly(ListItemID)
    • SelectAll()
    • SetSelection([]ListItemID)
  • The list.Select API now adds to the selection (which is what the documentation said), rather than replacing it

TODO/ Concerns:

  • tests
  • This uses a slice of IDs to keep track of selection, and creates a new selection slice on any unselect operation. This makes thread-safety fairly easy, but comes with some performance tradeoffs:
    • Repeatedly unselecting items causes a lot of memory churn (UnselectAll is implemented efficiently)
    • setupListItem is now O(n) in number of selected items. This is a potential concern
    • Notifying onSelected/onUnselected callbacks is O(n^2) in operations that select multiple IDs at once (SelectAll, SetSelection)

Fixes #2575 (for list)

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style and have Since: line.

@gi-yt
Copy link

gi-yt commented Jul 28, 2024

any update on this?

@dweymouth
Copy link
Contributor Author

No updates, and I have implemented multi-select in my own Fyne app by having the row widgets instead of the list handle it. And I've realized it's a lot better in my case to have the selection state as part of the data model instead of managed by the list because it enables things like sorting the data with the selection following the data instead of the row number.

So I have lost a lot of motivation in moving this forward... but it's open source so feel free to pick it up yourself, or copy it into your app's codebase, or take a look at my app (Supersonic) for how to manage multi-select in your app code instead of the list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants