diff options
| author | Jeff Carr <[email protected]> | 2023-04-06 18:00:18 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-04-06 18:00:18 -0500 |
| commit | bf60121b6515681ac505e80cb6824ba6bd978c29 (patch) | |
| tree | cdb87a9169185da1c33827702ef1b405c3d1ed00 /toolkit/gocui/click.go | |
| parent | 70f8797122741ef61951d3400317173a1d9974da (diff) | |
gocui: callbacks work via a channel
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui/click.go')
| -rw-r--r-- | toolkit/gocui/click.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/toolkit/gocui/click.go b/toolkit/gocui/click.go index 0dadc8b..a43dab4 100644 --- a/toolkit/gocui/click.go +++ b/toolkit/gocui/click.go @@ -34,6 +34,7 @@ func (w *cuiWidget) doWidgetClick() { } else { w.setCheckbox(true) } + w.doUserEvent() case toolkit.Grid: me.rootNode.hideWidgets() w.placeGrid() @@ -47,10 +48,28 @@ func (w *cuiWidget) doWidgetClick() { } w.placeWidgets() w.toggleTree() + case toolkit.Button: + w.doUserEvent() default: } } +// this passes the user event back from the plugin +func (w *cuiWidget) doUserEvent() { + if (me.callback == nil) { + log(logError, "doUserEvent() no callback channel was configured") + return + } + var a toolkit.Action + a.WidgetId = w.id + a.Name = w.name + a.Text = w.text + a.B = w.b + a.ActionType = toolkit.User + me.callback <- a + log(logNow, "END: sent a button click callback()") +} + var toggle bool = true func (w *cuiWidget) toggleTree() { if (toggle) { |
