summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/controls.go2
-rw-r--r--redo/controls_windows.go3
-rw-r--r--redo/uitask.go19
-rw-r--r--redo/zz_test.go12
4 files changed, 18 insertions, 18 deletions
diff --git a/redo/controls.go b/redo/controls.go
index 3fb2a54..6de193a 100644
--- a/redo/controls.go
+++ b/redo/controls.go
@@ -25,6 +25,6 @@ type Button interface {
}
// NewButton creates a new Button with the given label text.
-func NewButton(text string) {
+func NewButton(text string) *button {
return newButton(text)
}
diff --git a/redo/controls_windows.go b/redo/controls_windows.go
index 81ad2ac..84b5625 100644
--- a/redo/controls_windows.go
+++ b/redo/controls_windows.go
@@ -47,7 +47,6 @@ type button struct {
var buttonclass = toUTF16("BUTTON")
func newButton(text string) *button {
- op: func() {
w := newWidget(buttonclass,
C.BS_PUSHBUTTON | C.WS_TABSTOP,
0)
@@ -70,7 +69,7 @@ func (b *button) Text() string {
}
func (b *button) SetText(text string) {
- return b.settext(text)
+ b.settext(text)
}
//export buttonClicked
diff --git a/redo/uitask.go b/redo/uitask.go
index 8b5e523..43068e7 100644
--- a/redo/uitask.go
+++ b/redo/uitask.go
@@ -5,6 +5,7 @@ package ui
import (
"runtime"
"sync"
+ "unsafe"
)
// Go initializes package ui.
@@ -42,7 +43,7 @@ func Stop() {
type event struct {
// All events internally return bool; those that don't will be wrapped around to return a dummy value.
- do func(c Doer) bool
+ do func() bool
lock sync.Mutex
}
@@ -50,31 +51,31 @@ type event struct {
func newEvent() *event {
return &event{
- do: func(c Doer) bool {
+ do: func() bool {
return false
},
}
}
-func (e *event) set(f func(Doer)) {
+func (e *event) set(f func()) {
e.lock.Lock()
defer e.lock.Unlock()
if f == nil {
- f = func(c Doer) {}
+ f = func() {}
}
- e.do = func(c Doer) bool {
- f(c)
+ e.do = func() bool {
+ f()
return false
}
}
-func (e *event) setbool(f func(Doer) bool) {
+func (e *event) setbool(f func() bool) {
e.lock.Lock()
defer e.lock.Unlock()
if f == nil {
- f = func(c Doer) bool {
+ f = func() bool {
return false
}
}
@@ -87,7 +88,7 @@ func (e *event) fire() bool {
e.lock.Lock()
defer e.lock.Unlock()
- return e.do(c)
+ return e.do()
}
// Common code for performing a requested action (ui.Do() or ui.Stop()).
diff --git a/redo/zz_test.go b/redo/zz_test.go
index 50a4aee..a0751dc 100644
--- a/redo/zz_test.go
+++ b/redo/zz_test.go
@@ -15,14 +15,14 @@ var closeOnClick = flag.Bool("close", false, "close on click")
func init() {
flag.Parse()
go Do(func() {
- w := NewWindow(Do, "Hello", 320, 240)
- b := NewButton(Do, "There")
+ w := NewWindow("Hello", 320, 240)
+ b := NewButton("There")
w.SetControl(b)
if *closeOnClick {
b.SetText("Click to Close")
}
done := make(chan struct{})
- w.OnClosing(func(c Doer) bool {
+ w.OnClosing(func() bool {
if *closeOnClick {
panic("window closed normally in close on click mode (should not happen)")
}
@@ -31,17 +31,17 @@ func init() {
done <- struct{}{}
return true
})
- b.OnClicked(func(c Doer) {
+ b.OnClicked(func() {
println("in OnClicked()")
if *closeOnClick {
- Wait(c, w.Close())
+ w.Close()
Stop()
done <- struct{}{}
}
})
w.Show()
<-done
- })()
+ })
err := Go()
if err != nil {
panic(err)