Skip to content

Commit

Permalink
Added clarification on method chaining. Resolves rivo#831
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo committed Apr 6, 2023
1 parent 5796b0c commit e22ce95
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,23 @@ are executed in the main goroutine and thus should not use
# Type Hierarchy
All widgets listed above contain the [Box] type. All of [Box]'s functions are
therefore available for all widgets, too.
therefore available for all widgets, too. Please note that if you are using the
functions of [Box] on a subclass, they will return a *Box, not the subclass. So
while tview supports method chaining in many places, these chains must be broken
when using [Box]'s functions. Example:
// This will cause "textArea" to be an empty Box.
textArea := tview.NewTextArea().
SetMaxLength(256).
SetPlaceholder("Enter text here").
SetBorder(true)
You will need to call [Box.SetBorder] separately:
textArea := tview.NewTextArea().
SetMaxLength(256).
SetPlaceholder("Enter text here")
texArea.SetBorder(true)
All widgets also implement the [Primitive] interface.
Expand Down

0 comments on commit e22ce95

Please sign in to comment.