mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #916] NewButton.SetBorder(true) & NewButton.SetBackgroundColor(tcell.Color*[ANY]) results in a Button Text Wipeout Issue!? #668
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#668
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @WhipMeHarder on GitHub (Nov 16, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/916
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
@rivo commented on GitHub (Nov 16, 2023):
SetBackgroundColor()returns aBox, not aButton. Some details on this here: https://pkg.go.dev/github.com/rivo/tview#hdr-Type_HierarchyThe solution would be something like this:
@WhipMeHarder commented on GitHub (Nov 16, 2023):
Ok. Yes! This works! The reason being, that chaining functions which belong to the same primitive may not necessarily be a subclass of it.