[GH-ISSUE #193] Option to not highlight selected list element when not focused #153

Closed
opened 2026-03-04 01:02:26 +03:00 by kerem · 2 comments
Owner

Originally created by @dimonomid on GitHub (Nov 23, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/193

Another thing is that the List primitive always highlights selected item, and it also makes it hard to unselect all items. In my app I have a few lists, but I need to highlight their items only when the list is focused. My workaround is to use SetCurrentItem(-1), but it only works when the list is empty; otherwise it selects the last item. So, when I need to modify the list, I had to Clear it first, then do SetCurrentItem(-1), and then add all items back. Ugh. :)

Would you be open to implementing some option to avoid highlighting of selected element while the list is not focused?

Originally created by @dimonomid on GitHub (Nov 23, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/193 Another thing is that the `List` primitive always highlights selected item, _and_ it also makes it hard to unselect all items. In my app I have a few lists, but I need to highlight their items only when the list is focused. My workaround is to use `SetCurrentItem(-1)`, *but* it only works when the list is empty; otherwise it selects the last item. So, when I need to modify the list, I had to `Clear` it first, then do `SetCurrentItem(-1)`, and then add all items back. Ugh. :) Would you be open to implementing some option to avoid highlighting of selected element while the list is not focused?
kerem closed this issue 2026-03-04 01:02:26 +03:00
Author
Owner

@rivo commented on GitHub (Nov 26, 2018):

I added this with the latest commit. You'll need to call list.SetSelectedFocusOnly(true).

<!-- gh-comment-id:441582513 --> @rivo commented on GitHub (Nov 26, 2018): I added this with the latest commit. You'll need to call `list.SetSelectedFocusOnly(true)`.
Author
Owner

@dimonomid commented on GitHub (Nov 26, 2018):

Cool, thanks!

<!-- gh-comment-id:441587722 --> @dimonomid commented on GitHub (Nov 26, 2018): Cool, thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#153
No description provided.