Tables, trees and lists
Widgets that keep real state are built once and placed with ui.ViewOf.
Table, Tree, FileTree, and ListView keep real state. Build them in Build*, then place them with ui.ViewOf:
func Build() *App {
app := &App{}
app.table = ui.NewTable(cols, actions)
return app
}
func (a *App) Body(c *ui.Ctx) ui.View {
return ui.Column(
ui.ViewOf(a.table).Grow(1),
).Grow(1)
}Constructing these inside Body resets caret, scroll, and selection every frame.
For the code editor, see Code editor; it is a retained widget too.
Edit this page on GitHub