2
0
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:
Oliver 2023-04-06 09:27:32 +02:00
parent 5796b0cd5c
commit e22ce9588b

18
doc.go
View File

@ -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.