summaryrefslogtreecommitdiff
path: root/checkbox.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-10-21 11:40:08 -0500
committerJeff Carr <[email protected]>2022-10-21 11:40:08 -0500
commita3fc02c2f7e22f92b76ff6db92618be0cf3656a6 (patch)
tree70c05aada2b3acfbb95d1e6e0098291c7f8b6bcf /checkbox.go
parentb8ef0bb05dc14bc4291f3d156b199fa125cdb9d7 (diff)
v0.4.1 set sane toolkit default look and feelv0.4.1
autogenerate README.md from doc.go (goreadme cmd) remove passing arguements on a mouse click() make defaults for padding, margin, stretchy, etc add a checkbox widget function rename to NewButton() keep cleaning up toolkit code fix date. I was somehow in the future Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'checkbox.go')
-rw-r--r--checkbox.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/checkbox.go b/checkbox.go
new file mode 100644
index 0000000..0284920
--- /dev/null
+++ b/checkbox.go
@@ -0,0 +1,48 @@
+package gui
+
+import "log"
+
+import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
+
+func (n *Node) verify() {
+ if (n.toolkit == nil) {
+ log.Println("gui/wit node.Verify(): toolkit == nil", n.Name)
+ panic("gui/wit node.Verify(): toolkit == nil")
+ }
+}
+
+func (n *Node) Checked() bool {
+ n.Dump()
+ return n.checked
+}
+
+func (n *Node) NewCheckbox(name string) *Node {
+ var newt *toolkit.Toolkit
+ var c *Node
+
+ log.Println("toolkit.NewCheckbox() START", name)
+
+ n.verify()
+
+ // make a *Node with a *toolkit.Group
+ c = n.New(name + " part1")
+ newt = n.toolkit.NewCheckbox(name)
+ newt.Name = name
+ c.toolkit = newt
+ c.custom = n.custom
+ newt.Custom = func () {
+ println("AM IN CALLBACK. SETTING NODE.checked START")
+ if newt.Checked() {
+ println("is checked")
+ c.checked = true
+ } else {
+ println("is not checked")
+ c.checked = false
+ }
+ commonCallback(c)
+ println("AM IN CALLBACK. SETTING NODE.checked END")
+ }
+ c.Dump()
+
+ return c
+}