From 70452bdaac9a558c6266f1f46121222c38e17487 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 9 Feb 2025 06:21:21 -0600 Subject: [PATCH] buttons disabled on window open --- eventMouseClick.go | 3 ++- treeAdd.go | 7 ++++++- treeDraw.go | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/eventMouseClick.go b/eventMouseClick.go index ce0b6a6..9e4aa1e 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -15,7 +15,8 @@ func (tk *guiWidget) doButtonClick() { tk.dumpWidget("click()") // enable this to debug widget clicks me.myTree.SendFromUser(tk.node) } else { - tk.dumpWidget("disabled()") // enable this to debug widget clicks + log.Info("button is currently disabled by the application") + // tk.dumpWidget("disabled()") // enable this to debug widget clicks } } diff --git a/treeAdd.go b/treeAdd.go index d20da80..766e373 100644 --- a/treeAdd.go +++ b/treeAdd.go @@ -67,7 +67,12 @@ func addWidget(n *tree.Node) { tk.color = &colorTab return case widget.Button: - tk.setColorButton() + if tk.node.IsEnabled() { + tk.setColorButton() + } else { + tk.setColorButton() + tk.setColorDisable() + } return case widget.Checkbox: tk.setColorInput() diff --git a/treeDraw.go b/treeDraw.go index f1e9b95..802e498 100644 --- a/treeDraw.go +++ b/treeDraw.go @@ -80,6 +80,14 @@ func (tk *guiWidget) drawView() { tk.v.Clear() fmt.Fprint(tk.v, tk.labelN) + // tmp hack to disable buttons on window open + if tk.node.WidgetType == widget.Button { + if tk.node.IsEnabled() { + } else { + tk.setColorDisable() + } + } + // if you don't do this here, it will be black & white only if tk.color != nil { tk.v.FrameColor = tk.color.frame