summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go38
1 files changed, 29 insertions, 9 deletions
diff --git a/main.go b/main.go
index bffbee9..4955ac9 100644
--- a/main.go
+++ b/main.go
@@ -19,7 +19,7 @@ func init() {
log.Log(NOW, "init() has been run")
me.counter = 0
- me.prefix = "wit"
+ // me.prefix = "wit"
// Populates the top of the binary tree
me.rootNode = addNode()
@@ -38,30 +38,50 @@ func init() {
go watchCallback()
}
+// lookup the widget by the id sent from the toolkit
+func (n *Node) findId(i int) (*Node) {
+ if (n == nil) {
+ return nil
+ }
+
+ if (n.id == i) {
+ return n
+ }
+
+ for _, child := range n.children {
+ newN := child.findId(i)
+ if (newN != nil) {
+ return newN
+ }
+ }
+ return nil
+}
+
func watchCallback() {
- log.Info("watchCallback() START")
+ log.Info("guiChan() START")
for {
- log.Info("watchCallback() restarted select for toolkit user events")
+ log.Info("guiChan() restarted")
select {
case a := <-me.guiChan:
if (a.ActionType == widget.UserQuit) {
- log.Info("doUserEvent() User sent Quit()")
+ log.Warn("guiChan() User sent Quit()")
me.rootNode.doCustom()
log.Exit("wit/gui toolkit.UserQuit")
break
}
if (a.ActionType == widget.EnableDebug) {
- log.Warn("doUserEvent() Enable Debugging Window")
- log.Warn("doUserEvent() TODO: not implemented")
+ log.Warn("guiChan() Enable Debugging Window")
+ log.Warn("guiChan() TODO: not implemented")
// DebugWindow()
break
}
- n := me.rootNode.FindId(a.WidgetId)
+ n := me.rootNode.findId(a.WidgetId)
if (n == nil) {
- log.Warn("watchCallback() UNKNOWN widget id =", a.WidgetId, a.ProgName)
+ log.Warn("guiChan() UNKNOWN widget id")
+ log.Warn("id =", a.WidgetId, a.ProgName)
} else {
- log.Info("watchCallback() FOUND widget id =", n.id, n.progname)
+ log.Verbose("guiChan() FOUND widget id =", n.id, n.progname)
n.doUserEvent(a)
}
// this maybe a good idea?