diff options
| author | Jeff Carr <[email protected]> | 2024-01-19 03:45:21 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-19 03:45:21 -0600 |
| commit | c682272f56094fc816c6b7fbee84351f5608c259 (patch) | |
| tree | cf737588d966aa847a1184d98ae8a890f3bb7ac9 | |
| parent | d4891c4d58380a81275d315151c2abc58ca1f291 (diff) | |
auto typist auto hides
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | action.go | 1 | ||||
| -rw-r--r-- | checkbox.go | 11 | ||||
| -rw-r--r-- | common.go | 6 | ||||
| -rw-r--r-- | structs.go | 3 |
4 files changed, 19 insertions, 2 deletions
@@ -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 @@ -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) } @@ -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() |
