[GH-ISSUE #141] SetBorder hides contents of List and TextView #111

Closed
opened 2026-03-04 01:02:01 +03:00 by kerem · 5 comments
Owner

Originally created by @viktordanov on GitHub (Jul 21, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/141

When calling the SetBorder function on a List or a TextView (might be exhibited by other widgets too), no matter the argument, the contents of the targeted view get hidden and the view appears empty.

OS: Ubuntu 18.04
Shell: Bash 4.4.19
Originally created by @viktordanov on GitHub (Jul 21, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/141 When calling the SetBorder function on a List or a TextView (might be exhibited by other widgets too), no matter the argument, the contents of the targeted view get hidden and the view appears empty. ``` OS: Ubuntu 18.04 Shell: Bash 4.4.19 ```
kerem closed this issue 2026-03-04 01:02:02 +03:00
Author
Owner

@rivo commented on GitHub (Jul 27, 2018):

I can't reproduce this. Can you send a short code snippet and a screenshot that illustrates this, please?

<!-- gh-comment-id:408457940 --> @rivo commented on GitHub (Jul 27, 2018): I can't reproduce this. Can you send a short code snippet and a screenshot that illustrates this, please?
Author
Owner

@viktordanov commented on GitHub (Jul 27, 2018):

Accourding to new observations, it appears that the issue is only present when the border is set using a chained .SetBorder function, which is most likely due to the output of the function. I appologize, if this is meant to function like this by design.

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

	textView2 := tview.NewTextView().SetText("2222222")
	textView2.SetBorder(true)

	mainView :=
		tview.NewFlex().SetDirection(tview.FlexColumn).
			AddItem(tview.NewTextView().SetText("sdsddas").SetBorder(true), 0, 4, false). // ISSUE PRESENT
			AddItem(textView2, 30, 2, false)                                              // ISSUE ABSENT

	if err := app.SetRoot(mainView, true).Run(); err != nil {
		panic(err)
	}
}

image

<!-- gh-comment-id:408475666 --> @viktordanov commented on GitHub (Jul 27, 2018): Accourding to new observations, it appears that the issue is only present when the border is set using a chained `.SetBorder` function, which is most likely due to the output of the function. I appologize, if this is meant to function like this by design. ``` func main() { app = tview.NewApplication() textView2 := tview.NewTextView().SetText("2222222") textView2.SetBorder(true) mainView := tview.NewFlex().SetDirection(tview.FlexColumn). AddItem(tview.NewTextView().SetText("sdsddas").SetBorder(true), 0, 4, false). // ISSUE PRESENT AddItem(textView2, 30, 2, false) // ISSUE ABSENT if err := app.SetRoot(mainView, true).Run(); err != nil { panic(err) } } ``` ![image](https://user-images.githubusercontent.com/7188510/43334198-5dfaad44-91d5-11e8-963d-b2ebc37ad87e.png)
Author
Owner

@rivo commented on GitHub (Jul 28, 2018):

I understand. Well, TextView inherits SetBorder() from Box and because SetBorder() returns a Box, if you assign the result to a variable, you have a Box on your hand, not a TextView:

iAmABox := tview.NewTextView().SetBorder(true)

This means that in your example, tview will call Box's Draw() function instead of TextView's Draw() function so it ends up empty.

I don't know of any way of changing the function's return value without duplicating all functions in the child classes. So at this point, the only thing you can do is this:

textView := tview.NewTextView()
textView.SetBorder(true)
<!-- gh-comment-id:408627226 --> @rivo commented on GitHub (Jul 28, 2018): I understand. Well, `TextView` inherits `SetBorder()` from `Box` and because `SetBorder()` returns a `Box`, if you assign the result to a variable, you have a `Box` on your hand, not a `TextView`: ```go iAmABox := tview.NewTextView().SetBorder(true) ``` This means that in your example, `tview` will call `Box`'s `Draw()` function instead of `TextView`'s `Draw()` function so it ends up empty. I don't know of any way of changing the function's return value without duplicating all functions in the child classes. So at this point, the only thing you can do is this: ```go textView := tview.NewTextView() textView.SetBorder(true) ```
Author
Owner

@viktordanov commented on GitHub (Jul 28, 2018):

I understand. Sacrificing good code structure for a little convenience is never worth it. Thanks for taking your time. 👍
Should I close this?

<!-- gh-comment-id:408627499 --> @viktordanov commented on GitHub (Jul 28, 2018): I understand. Sacrificing good code structure for a little convenience is never worth it. Thanks for taking your time. :+1: Should I close this?
Author
Owner

@rivo commented on GitHub (Aug 4, 2018):

I'll close it.

Not sure I'd say "never". I'm still wrestling with this decision because I tend to think that the convenience for the users (i.e. the developers who use tview) is more important. But it increases the boilerplate for every new primitive I introduce in the future, it duplicates a lot of code and documentation. And that's always a source for mistakes.

<!-- gh-comment-id:410437784 --> @rivo commented on GitHub (Aug 4, 2018): I'll close it. Not sure I'd say "never". I'm still wrestling with this decision because I tend to think that the convenience for the users (i.e. the developers who use `tview`) is more important. But it increases the boilerplate for every new primitive I introduce in the future, it duplicates a lot of code and documentation. And that's always a source for mistakes.
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#111
No description provided.