|
|
@@ -22,10 +22,6 @@ const (
|
|
|
height = 600
|
|
|
)
|
|
|
|
|
|
-// OnExit is the event generated by Application when the user
|
|
|
-// tries to close the window or the Exit() method is called.
|
|
|
-const OnExit = "app.OnExit"
|
|
|
-
|
|
|
// Application
|
|
|
type Application struct {
|
|
|
window.IWindow // Embedded GlfwWindow
|
|
|
@@ -74,14 +70,15 @@ func (app *Application) Run(update func(renderer *renderer.Renderer, deltaTime t
|
|
|
// Set up recurring calls to user's update function
|
|
|
for true {
|
|
|
// If Exit() was called or there was an attempt to close the window dispatch OnExit event for subscribers.
|
|
|
- // If no subscriber cancelled the event, terminates the application.
|
|
|
+ // If no subscriber cancelled the event, terminate the application.
|
|
|
if app.IWindow.(*window.GlfwWindow).ShouldClose() {
|
|
|
- canceled := app.Dispatch(OnExit, nil) // TODO implement the same in app-browser
|
|
|
- if canceled {
|
|
|
- app.IWindow.(*window.GlfwWindow).SetShouldClose(false)
|
|
|
- } else {
|
|
|
- break
|
|
|
- }
|
|
|
+ app.Dispatch(OnExit, nil)
|
|
|
+ // TODO allow for cancelling exit e.g. showing dialog asking the user if he/she wants to save changes
|
|
|
+ // if exit was cancelled {
|
|
|
+ // app.IWindow.(*window.GlfwWindow).SetShouldClose(false)
|
|
|
+ // } else {
|
|
|
+ break
|
|
|
+ // }
|
|
|
}
|
|
|
// Update frame start and frame delta
|
|
|
now := time.Now()
|