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 option in List to hide separators #3756

Closed
2 tasks done
dweymouth opened this issue Mar 22, 2023 · 8 comments
Closed
2 tasks done

Add option in List to hide separators #3756

dweymouth opened this issue Mar 22, 2023 · 8 comments

Comments

@dweymouth
Copy link
Contributor

Checklist

  • I have searched the issue tracker for open issues that relate to the same feature, before opening a new one.
  • This issue only relates to a single feature. I will open new issues for any other features.

Is your feature request related to a problem?

The List widget has a lot of nice builtins but if the developer wants a non-interactive list (eg to display a log file as recently discussed in the discord), or if the row widgets themselves handle interactivity, then it is not really suitable to use the existing List without forking it to comment out builtin behavior.

Is it possible to construct a solution with the existing API?

No response

Describe the solution you'd like to see.

The List widget should have new publicly exported flags:

type List struct {
    // ...
    DisableSelection bool
    DisableRowFocus bool
    DisableHover bool
    NoSeparator bool
    // ...
}

Or perhaps DisableSelection should disable rows being focusable and hoverable as well, and in that case be named DisableInteractivity?

Also, maybe instead of DisableSelection, have a new enum SelectionMode once multi-select is actually implemented:

type SelectionMode int

const (
    SelectionModeSingle SelectionMode = iota // default, since existing behavior is single-select
    SelectionModeMulti
    SelectionModeNone
)
@andydotxyz
Copy link
Member

andydotxyz commented Mar 26, 2023

or if the row widgets themselves handle interactivity, then it is not really suitable to use the existing List without forking it to comment out builtin behavior.

In this case we don't have to worry as the child widgets will override the behaviour in the List (as child interaction always has preference over parent).
With this in mind selection and hover can easily be handled in other ways.

Focus is a little more problematic as the implementation is a little closed in its current setup.
This is something on my list to improve, so maybe lets come back to it after that.

I think this leaves the separator request only. To be consistent with the general hide/show should we go HideSeparators?

@andydotxyz andydotxyz added this to the Dalwhinnie (May/June 2023) milestone Mar 26, 2023
@dweymouth
Copy link
Contributor Author

Yeah I like HideSeparators as a name. Agree that focus is really the only one that requires forking the List code if you don't want it since the other behaviors can be overridden by the row widgets.

@dweymouth
Copy link
Contributor Author

Wanted to revisit this discussion to talk about what disabling focus could look like, API-wise, for the collection widgets. @Jacalz and I discussed adding selection to the GridWrap widget in fyne-x to prep for moving it into Fyne. If selection is added, however, I will have to maintain a fork of the widget to keep using it in my project (as I already do with List) because I need builtin focusability of the items to be disabled.

@andydotxyz
Copy link
Member

Ah, that is indeed particularly problematic because implementing an interface such as Focusable is done at compile time and a runtime switch can't disable it.
Disabling selection and dividers / space is easier as these are done at runtime.
Might need a bit of exploration here!

@dweymouth
Copy link
Contributor Author

How do disableable widgets like button reject the focus when they are disabled? Maybe a similar strategy could be used?

@andydotxyz
Copy link
Member

The focus manager understands the Disabled interface and avoids focusing those widgets.

@dweymouth dweymouth changed the title Add disable flags for some builtin List behaviors Add option in List to hide separators Apr 23, 2024
@dweymouth
Copy link
Contributor Author

Just updating to clarify that a hide separators option is the only thing that needs to be added, API-wise. Everything else can be achieved by extending widget.List and making it Disableable and disabled.

@dweymouth
Copy link
Contributor Author

On develop for 2.5.0

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

No branches or pull requests

2 participants