Add option in List to hide separators
Checklist
- [X] I have searched the issue tracker for open issues that relate to the same feature, before opening a new one.
- [X] 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
)
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?
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.
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.
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!
How do disableable widgets like button reject the focus when they are disabled? Maybe a similar strategy could be used?
The focus manager understands the Disabled interface and avoids focusing those widgets.
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.
On develop for 2.5.0