Updated the test program to be Request-less. Now to test...

This commit is contained in:
Pietro Gagliardi 2014-07-19 09:58:57 -04:00
parent 104337188f
commit 32061353a1
1 changed files with 11 additions and 11 deletions

View File

@ -14,15 +14,15 @@ var closeOnClick = flag.Bool("close", false, "close on click")
// because Cocoa hates being run off the main thread, even if it's run exclusively off the main thread // because Cocoa hates being run off the main thread, even if it's run exclusively off the main thread
func init() { func init() {
flag.Parse() flag.Parse()
go func() { go Do(func() {
w := GetNewWindow(Do, "Hello", 320, 240) w := NewWindow(Do, "Hello", 320, 240)
b := GetNewButton(Do, "There") b := NewButton(Do, "There")
Wait(Do, w.SetControl(b)) w.SetControl(b)
if *closeOnClick { if *closeOnClick {
Wait(Do, b.SetText("Click to Close")) b.SetText("Click to Close")
} }
done := make(chan struct{}) done := make(chan struct{})
Wait(Do, w.OnClosing(func(c Doer) bool { w.OnClosing(func(c Doer) bool {
if *closeOnClick { if *closeOnClick {
panic("window closed normally in close on click mode (should not happen)") panic("window closed normally in close on click mode (should not happen)")
} }
@ -30,18 +30,18 @@ func init() {
Stop() Stop()
done <- struct{}{} done <- struct{}{}
return true return true
})) })
Wait(Do, b.OnClicked(func(c Doer) { b.OnClicked(func(c Doer) {
println("in OnClicked()") println("in OnClicked()")
if *closeOnClick { if *closeOnClick {
Wait(c, w.Close()) Wait(c, w.Close())
Stop() Stop()
done <- struct{}{} done <- struct{}{}
} }
})) })
Wait(Do, w.Show()) w.Show()
<-done <-done
}() })()
err := Go() err := Go()
if err != nil { if err != nil {
panic(err) panic(err)