mirror of
https://github.com/rivo/tview.git
synced 2024-11-15 06:12:46 +00:00
Added clarification on method chaining. Resolves #831
This commit is contained in:
parent
5796b0cd5c
commit
e22ce9588b
18
doc.go
18
doc.go
@ -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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user