Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetLabelColor on Button appears to be not working? #947

Open
tlafebre opened this issue Feb 8, 2024 · 1 comment
Open

SetLabelColor on Button appears to be not working? #947

tlafebre opened this issue Feb 8, 2024 · 1 comment

Comments

@tlafebre
Copy link

tlafebre commented Feb 8, 2024

Hello,

Please consider the simplified example below.

I want to change the color of "otherButton" if "button" is pressed. Pressing the "button" doesn't change the Label color of the "otherButton".

otherButton.SetLabel will change the text of the button however... What am I missing?

package main

import (
	"log"

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

var (
	button      *tview.Button
	otherButton *tview.Button
)

func main() {
	app := tview.NewApplication()

	grid := tview.NewGrid()

	button = tview.NewButton("Ok").SetSelectedFunc(func() {
		//otherButton.SetLabel("42")
		otherButton.SetLabelColor(tcell.ColorRed)
	})

	otherButton = tview.NewButton("Other")

	grid.
		AddItem(button, 0, 0, 1, 1, 0, 0, true).
		AddItem(otherButton, 2, 0, 1, 1, 0, 0, false)

	if err := app.SetRoot(grid, true).Run(); err != nil {
		log.Fatalf("Error")
	}

	app.SetFocus(button)
}

Thanks in advance!

@rivo
Copy link
Owner

rivo commented Mar 7, 2024

When I'm trying your code, it does what it's supposed to do:

image

After pressing Enter otherButton is the same text ("Other") but with a red label.

So I'm not sure what you're seeing on your end. Can you run this exact code and send a screenshot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants