[GH-ISSUE #486] Border stops treeview rendering properly #352

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

Originally created by @rmasp98 on GitHub (Aug 18, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/486

Hi,

This is a really cool library and hoping to use it on my project!

The issue is that when creating a TreeView, if you call SetBorder(true) on the object, it stops the contents of the treeview from rendering. The really simple example below should hopefully reproduce:

root := tview.NewTreeNode("Test")
tree := tview.NewTreeView().SetRoot(root).SetCurrentNode(root).SetBorder(true)
if err := tview.NewApplication().SetRoot(tree, true).Run(); err != nil {
	panic(err)
}

This should display the word "Test" with a border around the outside of the window but "Test" is not rendered.

OS: Arch Linux
Go version: 1.14.6
tview version: master (c65badfc3d...)

Happy to help fix the problem but might need some pointers around the code base (still fairly new to go)

Originally created by @rmasp98 on GitHub (Aug 18, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/486 Hi, This is a really cool library and hoping to use it on my project! The issue is that when creating a TreeView, if you call SetBorder(true) on the object, it stops the contents of the treeview from rendering. The really simple example below should hopefully reproduce: ```golang root := tview.NewTreeNode("Test") tree := tview.NewTreeView().SetRoot(root).SetCurrentNode(root).SetBorder(true) if err := tview.NewApplication().SetRoot(tree, true).Run(); err != nil { panic(err) } ``` This should display the word "Test" with a border around the outside of the window but "Test" is not rendered. OS: Arch Linux Go version: 1.14.6 tview version: master (c65badfc3d...) Happy to help fix the problem but might need some pointers around the code base (still fairly new to go)
kerem closed this issue 2026-03-04 01:04:15 +03:00
Author
Owner

@rivo commented on GitHub (Sep 15, 2020):

That's because the SetBorder() function is actually a function of Box and it returns a *tview.Box. So your tree variable is an instance of Box and it will call the Draw() function of Box to draw itself instead of calling TreeView.Draw(). Boxes are just empty boxes without any content.

Here's what you should do to ensure that tree is a *tview.TreeView:

package main

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

func main() {
	root := tview.NewTreeNode("Test")
	tree := tview.NewTreeView().SetRoot(root).SetCurrentNode(root)
	tree.SetBorder(true)
	if err := tview.NewApplication().SetRoot(tree, true).Run(); err != nil {
		panic(err)
	}
}

Let me know if this answers you question.

<!-- gh-comment-id:692687113 --> @rivo commented on GitHub (Sep 15, 2020): That's because the `SetBorder()` function is actually a function of `Box` and it returns a `*tview.Box`. So your `tree` variable is an instance of `Box` and it will call the `Draw()` function of `Box` to draw itself instead of calling `TreeView.Draw()`. Boxes are just empty boxes without any content. Here's what you should do to ensure that `tree` is a `*tview.TreeView`: ```go package main import ( "github.com/rivo/tview" ) func main() { root := tview.NewTreeNode("Test") tree := tview.NewTreeView().SetRoot(root).SetCurrentNode(root) tree.SetBorder(true) if err := tview.NewApplication().SetRoot(tree, true).Run(); err != nil { panic(err) } } ``` Let me know if this answers you question.
Author
Owner

@rivo commented on GitHub (Nov 17, 2020):

If you still require information, please open another issue and reference this one.

<!-- gh-comment-id:729137334 --> @rivo commented on GitHub (Nov 17, 2020): If you still require information, please open another issue and reference this one.
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#352
No description provided.