From aa491036c319beb8326fc422a0efdadf7337cda5 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 15 Jan 2024 16:14:48 -0600 Subject: add Destroy() improve syntax shortcuts go mod update Signed-off-by: Jeff Carr --- common.go | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'common.go') diff --git a/common.go b/common.go index 7430f98..c6397fa 100644 --- a/common.go +++ b/common.go @@ -33,13 +33,19 @@ func (n *Node) Hide() *Node { if ! n.Ready() { return n } if n.Hidden() { return n } + if n.WidgetType == widget.Window { log.Warn("Hide on a window", n.progname) log.Warn("this needs to do TestDestroy() ?") + n.Destroy() + n.hidden = true + n.changed = true + return nil } n.hidden = true n.changed = true + // inform the toolkits sendAction(n, widget.Hide) return n @@ -73,6 +79,18 @@ func (n *Node) Disable() *Node { return n } +func (n *Node) Destroy() { + if ! n.Ready() { return } + // if ! n.enabled { return } + + n.enabled = false + n.changed = true + + // inform the toolkits + sendAction(n, widget.Delete) + return +} + // add a new text string to widgets that support // multiple string values @@ -128,17 +146,17 @@ func (n *Node) GetBool() bool { } // should get the reference name used for programming and debugging -func (n *Node) SetProgName(s string) { - if ! n.Ready() { return } +func (n *Node) SetProgName(s string) *Node { + if ! n.Ready() { return n } if n.progname == s { // don't do anything since nothing changed - return + return n } n.changed = true n.progname = s - return + return n } /* -- cgit v1.2.3