diff --git a/demo-window.go b/demo-window.go index 751a3cc..16566c4 100644 --- a/demo-window.go +++ b/demo-window.go @@ -7,6 +7,9 @@ import _ "github.com/andlabs/ui/winmanifest" var mybox *ui.Box func (n *Node) AddGroup(title string) *Node { + if (n == nil) { + return nil + } hbox := n.uiBox if (hbox == nil) { return n diff --git a/entry.go b/entry.go index c24fe50..c10b7d0 100644 --- a/entry.go +++ b/entry.go @@ -42,11 +42,11 @@ func (b *GuiBox) GetText(name string) string { func (n *Node) SetText(value string) error { log.Println("gui.SetText() value =", value) - if (n.uiText == nil) { + if (n.uiText != nil) { n.uiText.SetText(value) return nil } - if (n.uiButton == nil) { + if (n.uiButton != nil) { n.uiButton.SetText(value) return nil } diff --git a/new-structs.go b/new-structs.go index 8c1f300..4f9989e 100644 --- a/new-structs.go +++ b/new-structs.go @@ -235,7 +235,8 @@ func (n *Node) AddTab(title string, uiC *ui.Box) *Node { log.Println("gui.Node.AddTab() START name =", title) if parent.uiWindow == nil { parent.Dump() - panic("gui.AddTab() ERROR ui.Window == nil") + log.Println("gui.Node.AddTab() ERROR ui.Window == nil") + return nil } if parent.box == nil { parent.Dump() diff --git a/window.go b/window.go index 40c4443..403638e 100644 --- a/window.go +++ b/window.go @@ -184,23 +184,26 @@ func NewWindow() *Node { w := Config.Width h := Config.Height - var node *Node - node = mapWindow(nil, nil, title, w, h) - box := node.box + var n *Node + n = mapWindow(nil, nil, title, w, h) + box := n.box log.Println("gui.NewWindow() title = box.Name =", box.Name) - node.uiNewWindow(box.Name, w, h) - window := node.uiWindow + n.uiNewWindow(box.Name, w, h) + window := n.uiWindow f := Config.Exit ui.OnShouldQuit(func() bool { - log.Println("createWindow().Destroy() on node.Name =", node.Name) + log.Println("createWindow().Destroy() on node.Name =", n.Name) if (f != nil) { - f(node) + f(n) } return true }) box.Window.UiWindow = window - return node + if(n.uiWindow == nil) { + panic("node.uiWindow == nil. This should never happen") + } + return n }