summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-19 03:45:21 -0600
committerJeff Carr <[email protected]>2024-01-19 03:45:21 -0600
commitc682272f56094fc816c6b7fbee84351f5608c259 (patch)
treecf737588d966aa847a1184d98ae8a890f3bb7ac9
parentd4891c4d58380a81275d315151c2abc58ca1f291 (diff)
auto typist auto hides
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--action.go1
-rw-r--r--checkbox.go11
-rw-r--r--common.go6
-rw-r--r--structs.go3
4 files changed, 19 insertions, 2 deletions
diff --git a/action.go b/action.go
index ddad70b..2a1f857 100644
--- a/action.go
+++ b/action.go
@@ -50,6 +50,7 @@ func sendAction(n *Node, atype widget.ActionType) {
a.State.ProgName = n.progname
a.State.Label = n.label
a.State.Value = n.value
+ a.State.Checked = n.checked
a.State.Direction = n.direction
for s, _ := range n.strings {
a.State.Strings = append(a.State.Strings, s)
diff --git a/checkbox.go b/checkbox.go
index 9760032..f863f8e 100644
--- a/checkbox.go
+++ b/checkbox.go
@@ -6,7 +6,14 @@ import (
)
func (n *Node) Checked() bool {
- return widget.GetBool(n.value)
+ return n.checked
+}
+
+func (n *Node) SetChecked(b bool) *Node {
+ // inform the toolkits
+ n.checked = b
+ sendAction(n, widget.Checked)
+ return n
}
func (parent *Node) NewCheckbox(name string) *Node {
@@ -15,7 +22,7 @@ func (parent *Node) NewCheckbox(name string) *Node {
newNode.progname = name
newNode.Custom = func() {
- log.Warn("checkboxy now is", newNode.value)
+ log.Warn("checkboxy now is", newNode.checked)
}
// inform the toolkits
diff --git a/common.go b/common.go
index 56ad5d5..d24b7fb 100644
--- a/common.go
+++ b/common.go
@@ -96,6 +96,12 @@ func (n *Node) Bool() bool {
return false
}
+ switch n.WidgetType {
+ case widget.Checkbox:
+ return n.checked
+ default:
+ }
+
return widget.GetBool(n.value)
}
diff --git a/structs.go b/structs.go
index 68a47d1..0fef186 100644
--- a/structs.go
+++ b/structs.go
@@ -111,6 +111,9 @@ type Node struct {
// how to arrange widgets
direction widget.Orientation
+ // for widgets that have on/off things
+ checked bool
+
// this function is run when there are mouse or keyboard events
Custom func()