Skip to content

Commit fd80f22

Browse files
committed
Added ability to override the WindowCloseEvent
1 parent 4ff9d58 commit fd80f22

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/RealEngine/Core/Application.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ namespace RealEngine {
7575
RE_PROFILE_FUNCTION();
7676

7777
EventDispatcher dispatcher(e);
78-
dispatcher.Dispatch<WindowCloseEvent>(RE_BIND_EVENT_FN(Application::OnWindowClose));
7978
dispatcher.Dispatch<WindowResizeEvent>(RE_BIND_EVENT_FN(Application::OnWindowResize));
8079

8180
for (auto it = m_LayerStack.end(); it != m_LayerStack.begin();) {
@@ -84,10 +83,15 @@ namespace RealEngine {
8483
break;
8584
}
8685
}
86+
87+
// This is in case one of the layers doesn't want to close
88+
dispatcher.Dispatch<WindowCloseEvent>(RE_BIND_EVENT_FN(Application::OnWindowClose));
8789
}
8890

8991
bool Application::OnWindowClose(WindowCloseEvent& e) {
9092
RE_PROFILE_FUNCTION();
93+
if (e.Handled) // This is a special case where a layer has already handled the close event
94+
return true;
9195

9296
Stop();
9397

0 commit comments

Comments
 (0)