From 1f3d664dbdee1b567f5b40e06c63c07c4667d5f4 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 28 Jan 2024 02:44:59 -0600 Subject: tree starts to work. 'M' lists internal gocui tree Signed-off-by: Jeff Carr --- widget.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'widget.go') diff --git a/widget.go b/widget.go index f854a3a..9c2a5c2 100644 --- a/widget.go +++ b/widget.go @@ -29,6 +29,21 @@ func initWidget(n *tree.Node) *guiWidget { w.heights = make(map[int]int) // how wide each column in the grid is } + p := n.Parent + if p == nil { + log.Log(ERROR, "parent == nil", w.String(), n.WidgetId, w.WidgetType) + return w + } + if p.TK == nil { + log.Log(ERROR, "parent.TK == nil", w.String(), n.WidgetId, w.WidgetType) + return w + } + + // set the parent and append to parent children + var ptk *guiWidget + ptk = p.TK.(*guiWidget) + w.parent = ptk + ptk.children = append(ptk.children, w) return w } -- cgit v1.2.3