From e8b090efe6d29d948629941a1ffb1ba9ca23e3a0 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 9 Feb 2024 09:30:23 -0600 Subject: [PATCH] gocui panic loads nocui Signed-off-by: Jeff Carr --- checkbox.go | 22 ++++++++++++++++++++++ main.go | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/checkbox.go b/checkbox.go index e5c730a..dac5e2e 100644 --- a/checkbox.go +++ b/checkbox.go @@ -2,9 +2,31 @@ package main import ( log "go.wit.com/log" + "go.wit.com/toolkits/tree" "go.wit.com/widget" ) +func setChecked(n *tree.Node, b bool) { + if n.WidgetType != widget.Checkbox { + } + var tk *guiWidget + tk = n.TK.(*guiWidget) + + if tk.node.State.Label == "" { + tk.node.State.Label = "BLANK" + } + if tk.node.State.Checked { + log.Log(WARN, "setCheckbox() got true", tk.node.State.Checked) + tk.labelN = "X " + tk.node.State.Label + } else { + log.Log(WARN, "setCheckbox() got false", tk.node.State.Checked) + tk.labelN = " " + tk.node.State.Label + } + + tk.Hide() + tk.Show() +} + // redraw the checkbox func (w *guiWidget) setCheckbox() { if w.node.WidgetType != widget.Checkbox { diff --git a/main.go b/main.go index 60760d0..2fb1b91 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,14 @@ import ( "go.wit.com/toolkits/tree" ) +func queueToolkitClose() { + me.baseGui.Close() +} + +func queueSetChecked(n *tree.Node, b bool) { + setChecked(n, b) +} + // sets defaults and establishes communication // to this toolkit from the wit/gui golang package func init() { @@ -33,6 +41,8 @@ func init() { me.myTree.SetLabel = newSetLabel me.myTree.SetText = newSetText me.myTree.AddText = newAddText + me.myTree.SetChecked = queueSetChecked + me.myTree.ToolkitClose = queueToolkitClose log.Log(NOW, "Init() start pluginChan") log.Sleep(.1) // probably not needed, but in here for now under development