[GH-ISSUE #630] improve text readability for selected TreeNodes #462

Closed
opened 2026-03-04 01:05:12 +03:00 by kerem · 3 comments
Owner

Originally created by @SoMuchForSubtlety on GitHub (Jul 31, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/630

Since the introduction of supporting transparency (#558), text colour of selected TreeView nodes has been problematic. I propose that instead of setting the foreground colour to white, we set it to the node colour offset plus a brightness offset (darker or brighter).

current behaviour proposed fix

I included this functionality in my original fix to enable transparency github.com/SoMuchForSubtlety/tview@88987c7f50

Originally created by @SoMuchForSubtlety on GitHub (Jul 31, 2021). Original GitHub issue: https://github.com/rivo/tview/issues/630 Since the introduction of supporting transparency (#558), text colour of selected TreeView nodes has been problematic. I propose that instead of setting the foreground colour to white, we set it to the node colour offset plus a brightness offset (darker or brighter). <table> <tr> <td>current behaviour <td>proposed fix <tr> <td><img src="https://user-images.githubusercontent.com/15961647/127752093-7513ecef-02ec-4eb4-b0e8-38cb519003b3.png"/> <td><img src="https://user-images.githubusercontent.com/15961647/127752129-9c463136-4424-4c40-9c73-446869c078ad.png"/> <tr> <td><img src="https://user-images.githubusercontent.com/15961647/127752097-de087b86-ae03-4626-96b1-5fc9df3d74f2.png"/> <td><img src="https://user-images.githubusercontent.com/15961647/127752140-150cac18-f718-453c-8522-34a86838fe97.png"/> </table> I included this functionality in my original fix to enable transparency https://github.com/SoMuchForSubtlety/tview/commit/88987c7f5054f63ac1f141b0138e68383fbe2a5a
kerem closed this issue 2026-03-04 01:05:12 +03:00
Author
Owner

@rivo commented on GitHub (Aug 22, 2021):

Why does the text of the selected nodes in your "current behaviour" example remain white? The code simply inverts the colours of selected nodes:

github.com/rivo/tview@29d673af0c/treeview.go (L714-L718)

I would therefore expect the red items to be black on red and the white items to be black on white. (That's what it looks like in the TreeView demo, too.)

What have you set as the colours that makes it look like in your screenshot?

<!-- gh-comment-id:903317841 --> @rivo commented on GitHub (Aug 22, 2021): Why does the text of the selected nodes in your "current behaviour" example remain white? The code simply inverts the colours of selected nodes: https://github.com/rivo/tview/blob/29d673af0ce2281f8b517d1bd14aab453b8fc8ef/treeview.go#L714-L718 I would therefore expect the red items to be black on red and the white items to be black on white. (That's what it looks like in the `TreeView` demo, too.) What have you set as the colours that makes it look like in your screenshot?
Author
Owner

@SoMuchForSubtlety commented on GitHub (Aug 24, 2021):

tview.Styles.PrimitiveBackgroundColor is set to tcell.ColorDefault.

If I do the same for the TreeView example (and make files selectable) this is the result
image

<!-- gh-comment-id:904501386 --> @SoMuchForSubtlety commented on GitHub (Aug 24, 2021): `tview.Styles.PrimitiveBackgroundColor` is set to `tcell.ColorDefault`. If I do the same for the TreeView example (and make files selectable) this is the result ![image](https://user-images.githubusercontent.com/15961647/130597617-f108bfe6-6328-4c53-bb34-9b755e2462f9.png)
Author
Owner

@rivo commented on GitHub (Feb 15, 2022):

It's not advisable to use tcell.ColorDefault. Check out https://github.com/rivo/tview/wiki/FAQ for details.

<!-- gh-comment-id:1040329391 --> @rivo commented on GitHub (Feb 15, 2022): It's not advisable to use `tcell.ColorDefault`. Check out https://github.com/rivo/tview/wiki/FAQ for details.
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#462
No description provided.