rivo / tview

Terminal UI library with rich, interactive widgets — written in Golang
MIT License
11.12k stars 576 forks source link

Wrong color in DropDown SetListStyles #990

Closed eeeXun closed 3 months ago

eeeXun commented 6 months ago

In the following code, I want to set unselected background color to red.

package main

import (
    "github.com/gdamore/tcell/v2"
    "github.com/rivo/tview"
)

func main() {
    app := tview.NewApplication()
    dropdown := tview.NewDropDown().
        SetLabel("Select an option (hit Enter): ").
        SetOptions([]string{"A", "AA", "AAA", "AAAA", "AAAAA"}, nil)
    dropdown.SetListStyles(tcell.StyleDefault.Background(tcell.ColorRed), tcell.StyleDefault)
    if err := app.SetRoot(dropdown, true).SetFocus(dropdown).Run(); err != nil {
        panic(err)
    }
}

This is before 03bdc867bee4ce7355079090c396d9ec861fc4bb image

This is after 03bdc867bee4ce7355079090c396d9ec861fc4bb, some areas did not change to red. image

rivo commented 3 months ago

The latest commit should give you the previous behaviour again.

However, I should note that using tcell.ColorDefault will almost always have unintended side effects. Your code uses these implicitly by using tcell.StyleDefault. I would advise you to always specify an actual color for both background and foreground (unselected and selected).