diff --git a/plugin.go b/plugin.go index ebe5ae3..223d4e5 100644 --- a/plugin.go +++ b/plugin.go @@ -75,12 +75,37 @@ func action(a widget.Action) { } else { // widget was already hidden } + case widget.Delete: + if w == nil { + return + } else { + w.hideWidgets() + w.deleteNode() + } + n.DeleteNode() + wRoot := me.treeRoot.TK.(*guiWidget) + wRoot.redoWindows(0, 0) default: - log.Log(ERROR, "action() ActionType =", a.ActionType, "WidgetType =", a.WidgetType, "Name =", a.ProgName) + log.Log(ERROR, "action() UNKNOWN Action Type =", a.ActionType, "WidgetType =", a.WidgetType, "Name =", a.ProgName) } log.Log(INFO, "action() END") } +func (w *guiWidget) deleteNode() { + p := w.parent + for i, child := range p.children { + log.Log(NOW, "parent has child:", i, child.cuiName, child.String()) + if w == child { + log.Log(NOW, "Found child ==", i, child.cuiName, child.String()) + log.Log(NOW, "Found n ==", i, w.cuiName, w.String()) + p.children = append(p.children[:i], p.children[i+1:]...) + } + } + for i, child := range p.children { + log.Log(NOW, "parent now has child:", i, child.cuiName, child.String()) + } +} + func (w *guiWidget) AddText(text string) { if w == nil { log.Log(NOW, "widget is nil") diff --git a/view.go b/view.go index 4da4ada..633eaa4 100644 --- a/view.go +++ b/view.go @@ -169,6 +169,9 @@ func (w *guiWidget) recreateView() { } func (w *guiWidget) hideWidgets() { + if w == nil { + return + } w.isCurrent = false switch w.node.WidgetType { case widget.Root: