summaryrefslogtreecommitdiff
path: root/toolkit/andlabs
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/andlabs')
-rw-r--r--toolkit/andlabs/common.go27
-rw-r--r--toolkit/andlabs/main.go7
-rw-r--r--toolkit/andlabs/plugin.go2
-rw-r--r--toolkit/andlabs/structs.go3
-rw-r--r--toolkit/andlabs/window.go3
5 files changed, 30 insertions, 12 deletions
diff --git a/toolkit/andlabs/common.go b/toolkit/andlabs/common.go
index cddea3e..d905e5c 100644
--- a/toolkit/andlabs/common.go
+++ b/toolkit/andlabs/common.go
@@ -6,10 +6,10 @@ import (
func (t *andlabsT) commonChange(tw *toolkit.Widget, wId int) {
log(debugChange, "commonChange() START widget =", t.Name, t.WidgetType)
- if (sendToChan(wId)) {
- log(debugChange, "commonChange() END attempted channel worked", t.Name, t.WidgetType)
- return
- }
+// if (sendToChan(wId)) {
+// log(debugChange, "commonChange() END attempted channel worked", t.Name, t.WidgetType)
+// return
+// }
if (tw == nil) {
log(true, "commonChange() What the fuck. there is no widget t.tw == nil")
return
@@ -28,11 +28,20 @@ func (t *andlabsT) commonChange(tw *toolkit.Widget, wId int) {
log(debugChange, "commonChange() END Widget.Custom()", t.Name, t.WidgetType)
}
-func sendToChan(i int) bool {
+func (t *andlabsT) doUserEvent() {
if (callback == nil) {
- log(debugError, "commonChange() SHOULD SEND int back here, but callback == nil", i)
- return false
+ log(debugError, "douserEvent() callback == nil", t.wId)
+ return
}
- log(debugError, "commonChange() Running callback() i =", i)
- return callback(i)
+ var a toolkit.Action
+ a.WidgetId = t.wId
+ a.Name = t.Name
+ a.S = t.s
+ a.I = t.i
+ a.B = t.b
+ a.ActionType = toolkit.User
+ log(logNow, "START: send a user event to the callback channel")
+ callback <- a
+ log(logNow, "END: sent a user event to the callback channel")
+ return
}
diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go
index 1ad7a60..9ca71ca 100644
--- a/toolkit/andlabs/main.go
+++ b/toolkit/andlabs/main.go
@@ -2,7 +2,7 @@ package main
import (
"embed"
- // "git.wit.org/wit/gui/toolkit"
+ "git.wit.org/wit/gui/toolkit"
"github.com/andlabs/ui"
// the _ means we only need this for the init()
@@ -22,6 +22,11 @@ func Main(f func()) {
})
}
+// this sets the channel to send user events back from the plugin
+func Callback(guiCallback chan toolkit.Action) {
+ callback = guiCallback
+}
+
// Other goroutines must use this to access the GUI
//
// You can not acess / process the GUI thread directly from
diff --git a/toolkit/andlabs/plugin.go b/toolkit/andlabs/plugin.go
index 2cac13c..8282621 100644
--- a/toolkit/andlabs/plugin.go
+++ b/toolkit/andlabs/plugin.go
@@ -31,12 +31,14 @@ func Action(a *toolkit.Action) {
rawAction(a)
}
+ /*
if (callback == nil) {
if (a.Callback != nil) {
log(debugNow, "setting Callback", a.Callback)
callback = a.Callback
}
}
+ */
// f()
Queue(f)
diff --git a/toolkit/andlabs/structs.go b/toolkit/andlabs/structs.go
index 9cc1b9d..4ab83a2 100644
--- a/toolkit/andlabs/structs.go
+++ b/toolkit/andlabs/structs.go
@@ -6,7 +6,8 @@ import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
var andlabs map[int]*andlabsT
-var callback func(int) bool
+// var callback func(int) bool
+var callback chan toolkit.Action
// stores the raw toolkit internals
type andlabsT struct {
diff --git a/toolkit/andlabs/window.go b/toolkit/andlabs/window.go
index f00e1ee..4b64b12 100644
--- a/toolkit/andlabs/window.go
+++ b/toolkit/andlabs/window.go
@@ -27,7 +27,8 @@ func newWindow(a *toolkit.Action) {
win.SetBorderless(canvas)
win.SetMargined(margin)
win.OnClosing(func(*ui.Window) bool {
- newt.commonChange(newt.tw, a.WidgetId)
+ // newt.commonChange(newt.tw, a.WidgetId)
+ newt.doUserEvent()
return true
})
win.Show()