From 190682f9c64dbe56f077da521ddfba181cb7bf1c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 10 Jan 2024 17:03:13 -0600 Subject: [PATCH] start fixing GetText() and move to any Signed-off-by: Jeff Carr --- common.go | 5 ++++- main.go | 6 ++++++ structs.go | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common.go b/common.go index 614a749..28be258 100644 --- a/common.go +++ b/common.go @@ -124,8 +124,11 @@ func (n *Node) AppendText(str string) { // should get the value of the node func (n *Node) GetText() string { + if n.value != nil { + return n.value.(string) + } if (n.S != n.Text) { - log.Warn("GetText() is screwed up. TODO: fix this dumb crap") + log.Warn("GetText() is screwed up. TODO: fix this dumb crap. n.S =", n.S, "and n.Text =", n.Text) } if (n.S != "") { return n.S diff --git a/main.go b/main.go index de7ed7c..61a31c0 100644 --- a/main.go +++ b/main.go @@ -81,6 +81,12 @@ func (n *Node) doCustom() { func (n *Node) doUserEvent(a widget.Action) { log.Info("doUserEvent() node =", n.id, n.Name) + if a.A != nil { + log.Warn("doUserEvent() a.A != nil", n.id, n.Name, "n.value =", a.A) + n.value = a.A + n.doCustom() + return + } switch n.WidgetType { case widget.Checkbox: n.B = a.B diff --git a/structs.go b/structs.go index 308aeb7..b84317d 100644 --- a/structs.go +++ b/structs.go @@ -90,6 +90,7 @@ type Node struct { I int S string B bool + value any // this function is run when there are mouse or keyboard events Custom func()