[GH-ISSUE #547] SetTitle() hides tview.List #401

Closed
opened 2026-03-04 01:04:39 +03:00 by kerem · 2 comments
Owner

Originally created by @natdm on GitHub (Jan 9, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/547

Taking the List "hello world" example and adding a SetTitle call to it:

package main

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

func main() {
	app := tview.NewApplication()
	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', func() {
			app.Stop()
		}).SetTitle("Borked")
	if err := app.SetRoot(list, true).EnableMouse(true).Run(); err != nil {
		panic(err)
	}
}

will not render anything to the console.

Originally created by @natdm on GitHub (Jan 9, 2021). Original GitHub issue: https://github.com/rivo/tview/issues/547 Taking the List "hello world" example and adding a SetTitle call to it: ```go package main import ( "github.com/rivo/tview" ) func main() { app := tview.NewApplication() 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', func() { app.Stop() }).SetTitle("Borked") if err := app.SetRoot(list, true).EnableMouse(true).Run(); err != nil { panic(err) } } ``` will not render anything to the console.
kerem closed this issue 2026-03-04 01:04:39 +03:00
Author
Owner

@rivo commented on GitHub (Jan 11, 2021):

SetTitle() is a function of Box and it returns an instance of Box. So your list variable actually points to a box, and this is what gets drawn. It has no border, thus no title, so nothing gets drawn.

If you want to add a title, put the SetTitle() call in a separate line:

list.SetTitle("Borked")
<!-- gh-comment-id:758170334 --> @rivo commented on GitHub (Jan 11, 2021): [`SetTitle()`](https://pkg.go.dev/github.com/rivo/tview#Box.SetTitle) is a function of `Box` and it returns an instance of `Box`. So your `list` variable actually points to a box, and this is what gets drawn. It has no border, thus no title, so nothing gets drawn. If you want to add a title, put the `SetTitle()` call in a separate line: ```go list.SetTitle("Borked") ```
Author
Owner

@natdm commented on GitHub (Jan 11, 2021):

Excellent. Amazing work here, man. Thank you!

<!-- gh-comment-id:758192448 --> @natdm commented on GitHub (Jan 11, 2021): Excellent. Amazing work here, man. Thank you!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#401
No description provided.