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

How to change the color of a background of inputField #940

Open
BrunProgramming opened this issue Jan 18, 2024 · 1 comment
Open

How to change the color of a background of inputField #940

BrunProgramming opened this issue Jan 18, 2024 · 1 comment

Comments

@BrunProgramming
Copy link

and trying to change the background color of the Inputfield
this is my code

package main

import (
	"github.com/rivo/tview"
)

var name string
var github string

var space = "═══════════════════════════════════"

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

	form := tview.NewForm().
		AddTextView("[#7D56F4]ʘ‿ʘ[white]", `Hellooo what is the name of your project?`, 40, 2, true, true).
    AddInputField("[#FEBB00]name", "[:red]", 20, func(textToCheck string, lastChar rune) bool {
			name = textToCheck
			return true
		}, nil).
    AddInputField("[#FEBB00]github repository:", "", 20, func(textToCheck string, lastChar rune) bool {
			github = textToCheck
			return true
		}, nil)
	form.AddButton("[#7D56F4]ʘ‿ʘ:Ready?", func() {
		app.Stop()
  })
	form.SetBorder(true).SetTitle(space + "Goxt cli").SetTitleAlign(tview.AlignLeft)
	if err := app.SetRoot(form, true).EnableMouse(true).Run(); err != nil {
		panic(err)
	}
}

I would appreciate anyone's help
thanks

@rivo
Copy link
Owner

rivo commented Mar 5, 2024

I guess SetFieldBackgroundColor is what you're looking for.

But if you want to change the colour of only one of the input fields, you'd probably have to use GetFormItem after constructing the form, cast to an input field, then change its attributes.

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