diff options
| author | Jeff Carr <[email protected]> | 2023-04-06 18:26:30 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-04-06 18:26:30 -0500 |
| commit | 9ce7f345f1a704516b298b495f8eefd3eaa37708 (patch) | |
| tree | b62bbdd662a628b57bc2f4b7c200f41c020f8334 | |
| parent | bf60121b6515681ac505e80cb6824ba6bd978c29 (diff) | |
gocui: debug flag buttons work
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | README-goreadme.md | 6 | ||||
| -rw-r--r-- | button.go | 2 | ||||
| -rw-r--r-- | main.go | 37 |
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` @@ -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) @@ -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) } } |
