apps: support DestroyEvent

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-13 11:43:54 +02:00
parent 59e92e8233
commit e13b9a4990
3 changed files with 20 additions and 30 deletions
+3 -9
View File
@@ -26,12 +26,8 @@ func main() {
// On iOS and Android main will never be called, so
// setting up the window must run in an init function.
func init() {
wopt := app.WindowOptions{Width: ui.Dp(800), Height: ui.Dp(600), Title: "Hello"}
w, err := app.NewWindow(&wopt)
if err != nil {
log.Fatal(err)
}
go func() {
w := app.NewWindow(nil)
if err := loop(w); err != nil {
log.Fatal(err)
}
@@ -52,10 +48,8 @@ func loop(w *app.Window) error {
for {
e := <-w.Events()
switch e := e.(type) {
case app.StageEvent:
if e.Stage == app.StageDead {
return w.Err()
}
case app.DestroyEvent:
return e.Err
case app.DrawEvent:
cfg = e.Config
cs := layout.ExactConstraints(w.Size())