rivo / tview

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

Button border disappeared when clicked #1012

Closed duguanyue closed 3 months ago

duguanyue commented 4 months ago

I tried to make a simple UI, and found that when the button was clicked, its border disappeared, and when it lost focus, its border appeared again, I don't know why. please help to check.

package main

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

func main() {
    app := tview.NewApplication()
    input := tview.NewInputField().
        SetPlaceholder("Input a number...").
        SetPlaceholderStyle(tcell.StyleDefault.Background(tcell.ColorBlack).Foreground(tcell.ColorGray)).
        SetFieldBackgroundColor(tcell.ColorBlack)
    input.SetBorder(true)

    button := tview.NewButton("QUERY").
        SetStyle(tcell.StyleDefault.Background(tcell.ColorBlack).Foreground(tcell.ColorGreenYellow)).
        SetActivatedStyle(tcell.StyleDefault.Background(tcell.ColorBlack).Foreground(tcell.ColorGreenYellow))
    button.SetBorder(true)

    display := tview.NewTextView()
    display.SetBorder(true).SetTitle("DISPLAY")

    extra := tview.NewBox().SetBorder(true).SetTitle("EXTRA")

    grid := tview.NewGrid().
        SetRows(3, 0).
        SetColumns(100, 0).
        AddItem(input, 0, 0, 1, 1, 0, 100, true).
        AddItem(button, 0, 1, 1, 1, 0, 0, false).
        AddItem(display, 1, 0, 1, 1, 0, 100, false).
        AddItem(extra, 1, 1, 1, 1, 0, 100, false)

    if err := app.SetRoot(grid, true).EnableMouse(true).Run(); err != nil {
        panic(err)
    }
}
image
rivo commented 3 months ago

This appears to have been a bug from some ill-conceived idea I had in the very beginning of this project. The latest commit should fix this.