rivo / tview

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

SetBackgroundColor doesn't work on Box #1033

Open ardawan opened 1 month ago

ardawan commented 1 month ago

I'm not sure if this is a bug or I'm not familiar with this package. Understand that each Flex type has a *Box as mentioned in the doc.

type Flex struct {
    *Box

    // The items to be positioned.
    items []*flexItem

    // FlexRow or FlexColumn.
    direction int

    // If set to true, Flex will use the entire screen as its available space
    // instead its box dimensions.
    fullScreen bool
}

But when I try to set the background color for the box, nothing will change.

f := tview.NewFlex().SetDirection(tview.FlexRow)
f.Box.SetBackgroundColor(tcell.ColorGreen)

So the question is how can we set a background color for the whole flex primitive?

rivo commented 1 month ago

Container primitives such as Flex or Grid don't clear the screen they occupy. So the background colour is ignored. One of the reasons is that they are used to position other elements on the screen. See for example the Wiki: https://github.com/rivo/tview/wiki/Modal