summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README-goreadme.md6
-rw-r--r--button.go2
-rw-r--r--main.go37
3 files changed, 37 insertions, 8 deletions
diff --git a/README-goreadme.md b/README-goreadme.md
index 5332004..b7222fc 100644
--- a/README-goreadme.md
+++ b/README-goreadme.md
@@ -137,7 +137,7 @@ Creates a window helpful for debugging this package
loads and initializes a toolkit (andlabs/ui, gocui, etc)
-### func [Main](/main.go#L143)
+### func [Main](/main.go#L170)
`func Main(f func())`
@@ -159,7 +159,7 @@ This should not pass a function
`func ShowDebugValues()`
-### func [StandardExit](/main.go#L204)
+### func [StandardExit](/main.go#L231)
`func StandardExit()`
@@ -252,7 +252,7 @@ You get a window
`func Start() *Node`
-#### func [StartS](/main.go#L129)
+#### func [StartS](/main.go#L156)
`func StartS(name string) *Node`
diff --git a/button.go b/button.go
index 8820734..c506e36 100644
--- a/button.go
+++ b/button.go
@@ -9,12 +9,14 @@ func (n *Node) NewButton(name string, custom func()) *Node {
a.Name = name
a.Text = name
a.ActionType = toolkit.Add
+ // deprecate this once andlabs is refactored
a.Callback = callback
newaction(&a, newNode, n)
return newNode
}
+// deprecate this once andlabs is refactored
func callback(i int) bool {
log(debugError, "callback() for widget id =", i)
n := Config.rootNode.FindId(i)
diff --git a/main.go b/main.go
index 80923ca..cda74a6 100644
--- a/main.go
+++ b/main.go
@@ -104,10 +104,6 @@ func Start() *Node {
return Config.rootNode
}
-func doSomething() {
- log(logNow, "doSomething()")
-}
-
func watchCallback() {
log(logNow, "makeCallback() START")
for {
@@ -115,8 +111,39 @@ func watchCallback() {
select {
case a := <-Config.guiChan:
log(logNow, "makeCallback() SELECT widget id =", a.WidgetId, a.Name)
- sleep(.5) // TODO: remove this. added while under development
+ n := Config.rootNode.FindId(a.WidgetId)
+ if (n == nil) {
+ log(logError, "makeCallback() SELECT widget id =", a.WidgetId, a.Name)
+ } else {
+ go n.doUserEvent(a)
+ }
+ // this maybe a good idea?
+ // TODO: Throttle user events somehow
+ sleep(.1)
+ }
+ }
+}
+
+func (n *Node) doUserEvent(a toolkit.Action) {
+ log(logNow, "doUserEvent() node =", n.id, n.Name)
+ switch n.WidgetType {
+ case toolkit.Checkbox:
+ n.B = a.B
+ log(logNow, "doUserEvent() Check =", n.id, n.Name, n.B)
+ if (n.Custom == nil) {
+ log(debugError, "Custom() = nil. SKIPPING")
+ return
+ }
+ n.Custom()
+ case toolkit.Button:
+ log(logNow, "doUserEvent() button =", n.id, n.Name)
+ if (n.Custom == nil) {
+ log(debugError, "Custom() = nil. SKIPPING")
+ return
}
+ n.Custom()
+ default:
+ log(logNow, "doUserEvent() type =", n.WidgetType)
}
}