summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README-goreadme.md6
-rw-r--r--main.go7
-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
7 files changed, 40 insertions, 15 deletions
diff --git a/README-goreadme.md b/README-goreadme.md
index b7222fc..a2f91b8 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#L170)
+### func [Main](/main.go#L177)
`func Main(f func())`
@@ -159,7 +159,7 @@ This should not pass a function
`func ShowDebugValues()`
-### func [StandardExit](/main.go#L231)
+### func [StandardExit](/main.go#L238)
`func StandardExit()`
@@ -252,7 +252,7 @@ You get a window
`func Start() *Node`
-#### func [StartS](/main.go#L156)
+#### func [StartS](/main.go#L163)
`func StartS(name string) *Node`
diff --git a/main.go b/main.go
index cda74a6..85d25aa 100644
--- a/main.go
+++ b/main.go
@@ -142,6 +142,13 @@ func (n *Node) doUserEvent(a toolkit.Action) {
return
}
n.Custom()
+ case toolkit.Window:
+ log(logNow, "doUserEvent() window =", n.id, n.Name)
+ if (n.Custom == nil) {
+ log(debugError, "Custom() = nil. SKIPPING")
+ return
+ }
+ n.Custom()
default:
log(logNow, "doUserEvent() type =", n.WidgetType)
}
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()