diff options
| author | Jeff Carr <[email protected]> | 2024-01-17 21:31:49 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-17 21:31:49 -0600 |
| commit | 841e6252c95244f0ee7faf2c01d33f69a8ab483a (patch) | |
| tree | ef400228622b87611168db2227269ba7fd56625d /tree/event.go | |
| parent | ba95c13799740b5f55541fc5e8ab9f1d34f7e421 (diff) | |
common tree package for toolkitsv0.12.4
This update provides *lots* of toolkit updates. This will allow
the next step of debugging the gocui toolkit to make it work
again. There are new common routines for handling the plugin
channel communication
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'tree/event.go')
| -rw-r--r-- | tree/event.go | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tree/event.go b/tree/event.go new file mode 100644 index 0000000..ee74138 --- /dev/null +++ b/tree/event.go @@ -0,0 +1,88 @@ +package tree + +/* + These code should be common to all gui plugins + + There are some helper functions that are probably going to be + the same everywhere. Mostly due to handling the binary tree structure + and the channel communication + + For now, it's just a symlink to the 'master' version in + ./toolkit/nocui/common.go +*/ + +import ( + "go.wit.com/log" + "go.wit.com/gui/widget" +) + +func (me *TreeInfo) DoEnableDebugger() { + if (me.callback == nil) { + log.Warn("DoUserEvent() toolkit panic() callback == nil") + return + } + var a widget.Action + a.ActionType = widget.EnableDebug + a.ProgName = me.PluginName + me.callback <- a + return +} + +func (me *TreeInfo) DoToolkitLoad(s string) { + if (me.callback == nil) { + log.Warn("DoUserEvent() toolkit load callback == nil") + return + } + var a widget.Action + a.ActionType = widget.ToolkitLoad + a.ProgName = me.PluginName + a.Value = s + log.Warn("DoUserEvent() START: toolkit load", s) + me.callback <- a + log.Warn("DoUserEvent() END: toolkit load", s) + return +} + +func (me *TreeInfo) DoToolkitPanic() { + if (me.callback == nil) { + log.Warn("DoUserEvent() toolkit panic() callback == nil") + return + } + var a widget.Action + a.ActionType = widget.ToolkitPanic + a.ProgName = me.PluginName + log.Info("DoUserEvent() START: toolkit panic()") + me.callback <- a + log.Info("DoUserEvent() END: toolkit panic()") + return +} + +func (me *TreeInfo) DoWindowCloseEvent(n *Node) { + if (me.callback == nil) { + log.Warn("DoUserEvent() callback == nil", n.WidgetId) + return + } + var a widget.Action + a.WidgetId = n.WidgetId + a.ActionType = widget.CloseWindow + log.Info("DoUserEvent() START: user closed the window", n.GetProgName()) + me.callback <- a + log.Info("DoUserEvent() END: user closed the window", n.GetProgName()) + return +} + +// Other goroutines must use this to access the GUI +func (me *TreeInfo) DoUserEvent(n *Node) { + if (me.callback == nil) { + log.Warn("DoUserEvent() callback == nil", n.WidgetId) + return + } + var a widget.Action + a.WidgetId = n.WidgetId + a.Value = n.State.Value + a.ActionType = widget.User + log.Info("DoUserEvent() START: send a user event to the callback channel") + me.callback <- a + log.Info("DoUserEvent() END: sent a user event to the callback channel") + return +} |
