summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-30 23:48:08 -0400
committerPietro Gagliardi <[email protected]>2014-06-30 23:48:08 -0400
commit3565889e15e387fce435c3ffadeaea9823fb2eed (patch)
tree93cf5de89c9010fc16da37949d441d97e3386f89 /test
parentffa1bbe0b91a8c812ddcea5c5d65e55f60d07f33 (diff)
Made Window.Closing a callback closure.
Diffstat (limited to 'test')
-rw-r--r--test/kbtest.go4
-rw-r--r--test/main.go18
2 files changed, 13 insertions, 9 deletions
diff --git a/test/kbtest.go b/test/kbtest.go
index 4e97708..9945772 100644
--- a/test/kbtest.go
+++ b/test/kbtest.go
@@ -75,9 +75,6 @@ func (a *keyboardArea) Key(e KeyEvent) (repaint bool) {
type kbhandler struct{}
func (kbhandler) Event(e Event, d interface{}) {
- if e == Closing {
- *(d.(*bool)) = true
- }
}
var doKeyboard = flag.Bool("kb", false, "run keyboard test (overrides -areabounds)")
@@ -85,6 +82,7 @@ func kbTest() {
wid, ht, ah := mkkbArea()
a := NewArea(wid, ht, ah)
w := NewWindow("Hi", wid, ht, kbhandler{})
+ w.Closing = func() bool { return true }
w.Open(a)
}
diff --git a/test/main.go b/test/main.go
index db01d15..52ce152 100644
--- a/test/main.go
+++ b/test/main.go
@@ -18,6 +18,12 @@ import (
type nullwinhandler struct{}
func (nullwinhandler) Event(Event, interface{}) {}
+func die() bool {
+ // TODO we want the bool return to happen before the Stop...
+ Stop <- struct{}{}
+ return true
+}
+
var prefsizetest = flag.Bool("prefsize", false, "")
func listboxPreferredSizeTest() *Window {
lb := NewListbox("xxxxx", "y", "zzz")
@@ -242,6 +248,7 @@ func areaTest() {
modaltest: modaltest,
repainttest: repainttest,
})
+ w.Closing = die
w.Open(layout)
go func() {
for t := range timechan {
@@ -264,9 +271,6 @@ type areatestwinhandler struct {
}
func (a *areatestwinhandler) Event(e Event, d interface{}) {
switch e {
- case Closing:
- *(d.(*bool)) = true
- Stop <- struct{}{}
case Clicked:
switch d {
case a.resize:
@@ -311,6 +315,7 @@ func areaboundsTest() {
w := NewWindow("Area Bounds Test", 320, 240, &areatestwinhandler{
a: a,
})
+ w.Closing = die
w.Open(a)
}
@@ -367,6 +372,10 @@ type testwinhandler struct {
func runMainTest() {
handler := new(testwinhandler)
handler.w = NewWindow("Main Window", 320, 240, handler)
+ handler.w.Closing = func() bool {
+ println("window closed event received")
+ return die()
+ }
handler.b = NewButton("Click Me")
handler.b2 = NewButton("Or Me")
handler.bmsg = NewButton("Or Even Me!")
@@ -481,9 +490,6 @@ func runMainTest() {
func (handler *testwinhandler) Event(e Event, d interface{}) {
switch e {
- case Closing:
- println("window closed event received")
- Stop <- struct{}{}
case Clicked:
switch d {
case handler.b: