gocui: debug flag buttons work
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
bddce3d5a3
commit
7cf0d45909
|
@ -137,7 +137,7 @@ Creates a window helpful for debugging this package
|
||||||
|
|
||||||
loads and initializes a toolkit (andlabs/ui, gocui, etc)
|
loads and initializes a toolkit (andlabs/ui, gocui, etc)
|
||||||
|
|
||||||
### func [Main](/main.go#L143)
|
### func [Main](/main.go#L170)
|
||||||
|
|
||||||
`func Main(f func())`
|
`func Main(f func())`
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ This should not pass a function
|
||||||
|
|
||||||
`func ShowDebugValues()`
|
`func ShowDebugValues()`
|
||||||
|
|
||||||
### func [StandardExit](/main.go#L204)
|
### func [StandardExit](/main.go#L231)
|
||||||
|
|
||||||
`func StandardExit()`
|
`func StandardExit()`
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ You get a window
|
||||||
|
|
||||||
`func Start() *Node`
|
`func Start() *Node`
|
||||||
|
|
||||||
#### func [StartS](/main.go#L129)
|
#### func [StartS](/main.go#L156)
|
||||||
|
|
||||||
`func StartS(name string) *Node`
|
`func StartS(name string) *Node`
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,14 @@ func (n *Node) NewButton(name string, custom func()) *Node {
|
||||||
a.Name = name
|
a.Name = name
|
||||||
a.Text = name
|
a.Text = name
|
||||||
a.ActionType = toolkit.Add
|
a.ActionType = toolkit.Add
|
||||||
|
// deprecate this once andlabs is refactored
|
||||||
a.Callback = callback
|
a.Callback = callback
|
||||||
newaction(&a, newNode, n)
|
newaction(&a, newNode, n)
|
||||||
|
|
||||||
return newNode
|
return newNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deprecate this once andlabs is refactored
|
||||||
func callback(i int) bool {
|
func callback(i int) bool {
|
||||||
log(debugError, "callback() for widget id =", i)
|
log(debugError, "callback() for widget id =", i)
|
||||||
n := Config.rootNode.FindId(i)
|
n := Config.rootNode.FindId(i)
|
||||||
|
|
37
main.go
37
main.go
|
@ -104,10 +104,6 @@ func Start() *Node {
|
||||||
return Config.rootNode
|
return Config.rootNode
|
||||||
}
|
}
|
||||||
|
|
||||||
func doSomething() {
|
|
||||||
log(logNow, "doSomething()")
|
|
||||||
}
|
|
||||||
|
|
||||||
func watchCallback() {
|
func watchCallback() {
|
||||||
log(logNow, "makeCallback() START")
|
log(logNow, "makeCallback() START")
|
||||||
for {
|
for {
|
||||||
|
@ -115,11 +111,42 @@ func watchCallback() {
|
||||||
select {
|
select {
|
||||||
case a := <-Config.guiChan:
|
case a := <-Config.guiChan:
|
||||||
log(logNow, "makeCallback() SELECT widget id =", a.WidgetId, a.Name)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (n *Node) LoadPlugin(name string) bool {
|
func (n *Node) LoadPlugin(name string) bool {
|
||||||
StartS(name)
|
StartS(name)
|
||||||
Redraw(name)
|
Redraw(name)
|
||||||
|
|
Loading…
Reference in New Issue