[GH-ISSUE #904] Dropdown List: Default Background Color is Immutable! #660

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

Originally created by @WhipMeHarder on GitHub (Oct 26, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/904

In the example of your Dropdown List, the colors for all objects can be changed, except for the default "green" background color of the Dropdown List.
For example, with the default code, I have modified it to this: -

app := tview.NewApplication() dropdown := tview.NewDropDown(). SetLabel("Choose the service that you want: (hit Enter): "). SetLabelColor(tcell.ColorBlue). SetFieldBackgroundColor(tcell.ColorRed). SetFieldTextColor(tcell.ColorBlue). SetPrefixTextColor(tcell.ColorYellow). SetOptions([]string{" First", " Second ", " Third", " Fourth ", " Fifth"}, nil) if err := app.SetRoot(dropdown, true).SetFocus(dropdown).Run(); err != nil { panic(err) }

Would you be willing to add a function such as: -

  • (d* DropDown) SetDropdownBackgroundColor(color tcell.Color)

Under "type DropDown", so that the code would look like this: -

app := tview.NewApplication() dropdown := tview.NewDropDown(). SetLabel("Choose the service that you want: (hit Enter): "). SetDropdownBackgroundColor(tcell.ColorBlue). SetOptions([]string{" First", " Second ", " Third", " Fourth ", " Fifth"}, nil) if err := app.SetRoot(dropdown, true).SetFocus(dropdown).Run(); err != nil { panic(err) }

Many thanks,

WhipMeHarder

Originally created by @WhipMeHarder on GitHub (Oct 26, 2023). Original GitHub issue: https://github.com/rivo/tview/issues/904 In the example of your Dropdown List, the colors for all objects can be changed, except for the default "green" background color of the Dropdown List. For example, with the default code, I have modified it to this: - ` app := tview.NewApplication() dropdown := tview.NewDropDown(). SetLabel("Choose the service that you want: (hit Enter): "). SetLabelColor(tcell.ColorBlue). SetFieldBackgroundColor(tcell.ColorRed). SetFieldTextColor(tcell.ColorBlue). SetPrefixTextColor(tcell.ColorYellow). SetOptions([]string{" First", " Second ", " Third", " Fourth ", " Fifth"}, nil) if err := app.SetRoot(dropdown, true).SetFocus(dropdown).Run(); err != nil { panic(err) }` Would you be willing to add a function such as: - - (d* DropDown) SetDropdownBackgroundColor(color tcell.Color) Under "type DropDown", so that the code would look like this: - `app := tview.NewApplication() dropdown := tview.NewDropDown(). SetLabel("Choose the service that you want: (hit Enter): "). SetDropdownBackgroundColor(tcell.ColorBlue). SetOptions([]string{" First", " Second ", " Third", " Fourth ", " Fifth"}, nil) if err := app.SetRoot(dropdown, true).SetFocus(dropdown).Run(); err != nil { panic(err) }` Many thanks, WhipMeHarder
kerem closed this issue 2026-03-04 01:06:50 +03:00
Author
Owner

@rivo commented on GitHub (Oct 26, 2023):

Such a function already exists. See SetListStyles().

<!-- gh-comment-id:1781893082 --> @rivo commented on GitHub (Oct 26, 2023): Such a function already exists. See [`SetListStyles()`](https://pkg.go.dev/github.com/rivo/tview#DropDown.SetListStyles).
Author
Owner

@WhipMeHarder commented on GitHub (Oct 29, 2023):

Thank you! I was just going to be rude and ask you if you could give me a code example of "SetListStyles", when I came across a link here:

https://github.com/rivo/tview/blob/8b7bcf9883df/dropdown.go#L210

WhipMeHarder

<!-- gh-comment-id:1784169003 --> @WhipMeHarder commented on GitHub (Oct 29, 2023): Thank you! I was just going to be rude and ask you if you could give me a code example of "SetListStyles", when I came across a link here: [https://github.com/rivo/tview/blob/8b7bcf9883df/dropdown.go#L210](url) WhipMeHarder
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#660
No description provided.