delete window

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-30 01:20:36 -06:00
parent 55735daeec
commit 50fe92a1b1
2 changed files with 29 additions and 1 deletions

View File

@ -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")

View File

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