Closed WhipMeHarder closed 1 year ago
SetBackgroundColor()
returns a Box
, not a Button
. Some details on this here: https://pkg.go.dev/github.com/rivo/tview#hdr-Type_Hierarchy
The solution would be something like this:
button := tview.NewButton("Button 1")
button.SetBackgroundColor( ... )
grid.AddItem(button, ... )
Ok. Yes! This works! The reason being, that chaining functions which belong to the same primitive may not necessarily be a subclass of it.
Hello Any/All, I have written some very simple code to test adding buttons to a tview Grid. However, when I try to change or customise the default attributes, the button text is automatically removed. Is there a way to prevent this, or a way to restore the original button text to the button so that it can be read? The original code when adding to a Grid is as follows:
app := tview.NewApplication()
grid := tview.NewGrid().
SetColumns(3, 45, 3).
SetRows(3,3,3,3).
AddItem(tview.NewButton("Button 1"), 0, 1, 1, 1, 0, 0, false)
I want your attention on the last line:
AddItem(tview.NewButton("Button 1"), 0, 1, 1, 1, 0, 0, false)
The moment I change the code by adding any of the following styles to tview.NewButton, the visible text, "Button 1", is deleted, as follows:
AddItem(tview.NewButton("Button 1").SetBackgroundColor(tcell.ColorWhite), 0, 1, 1, 1, 0, 0, false).
- Any color substituted has the same effect.Or,
AddItem(tview.NewButton("Button 1").SetBorder(true), 0, 1, 1, 1, 0, 0, false).
- Also removes the visible text, "Button 1", from the button object.Is there a remedy for this issue?
WhipMeharder