Adding a border removes the content of the element
justlunix opened this issue · comments
Hi, I have a problem where when I set the border on an element, the content won't be displayed anymore. I'm probably doing something wrong, so maybe someone can help me.
I think it's because the SetBorder returns a Box, so it "forgets" the other non-box settings. But I don't know how to fix it.
func Welcome() tview.Primitive {
return tview.NewFlex().
AddItem(nil, 0, 1, false).
AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(nil, 0, 1, false).
AddItem(connectionList(), 0, 1, false).
AddItem(nil, 0, 1, false), 0, 2, false).
AddItem(nil, 0, 1, false)
}
func hasConnections() bool {
return true
}
func connectionList() tview.Primitive {
if hasConnections() {
return tview.NewList().
AddItem("List item 1", "Some explanatory text", 'a', nil).
AddItem("List item 2", "Some explanatory text", 'b', nil).
AddItem("List item 3", "Some explanatory text", 'c', nil).
AddItem("List item 4", "Some explanatory text", 'd', nil).
AddItem("Quit", "Press to exit", 'q', nil).
SetBorder(true).
SetTitle("Connections")
} else {
return tview.NewTextView().
SetText("No connections found. Press 'a' to add a connection.").
SetBorder(true).
SetTitle("Connections")
}
}
If I remove the border it will display like this:
if hasConnections() {
return tview.NewList().
AddItem("List item 1", "Some explanatory text", 'a', nil).
AddItem("List item 2", "Some explanatory text", 'b', nil).
AddItem("List item 3", "Some explanatory text", 'c', nil).
AddItem("List item 4", "Some explanatory text", 'd', nil).
AddItem("Quit", "Press to exit", 'q', nil)
}
![image](https://private-user-images.githubusercontent.com/66276367/311540690-b5236208-5d69-4a44-8968-b150440fb6f0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzMTU4MjIsIm5iZiI6MTcyNTMxNTUyMiwicGF0aCI6Ii82NjI3NjM2Ny8zMTE1NDA2OTAtYjUyMzYyMDgtNWQ2OS00YTQ0LTg5NjgtYjE1MDQ0MGZiNmYwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAyVDIyMTg0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdhYjc3YTdkODE3NTJiZGIzNDBmY2UwOTI2MzY3MWI1MGUxZTJlNGI0MTYyNTRiNDE2N2UxM2Y3YjlkOTcyOTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.f9PVNrEMQrDSIhq60vWhosZ68FIukTXOj-Pi0seHCiQ)
Well, I knew it was something simple. Of course I need to call the methods without actually replacing the variable by the returned struct. :)
list := tview.NewList().
AddItem("List item 1", "Some explanatory text", 'a', nil).
AddItem("List item 2", "Some explanatory text", 'b', nil).
AddItem("List item 3", "Some explanatory text", 'c', nil).
AddItem("List item 4", "Some explanatory text", 'd', nil).
AddItem("Quit", "Press to exit", 'q', nil)
list.SetBorder(true).
SetTitle("Connections")
return list