Ver Fonte

LibGUI: Add Window::on_close hook

This will be invoked when the window is closed, which is helpful if you
want to remove the window from some kind of owner after it's closed.
Andreas Kling há 4 anos atrás
pai
commit
c381e7f5a0
2 ficheiros alterados com 3 adições e 0 exclusões
  1. 2 0
      Libraries/LibGUI/Window.cpp
  2. 1 0
      Libraries/LibGUI/Window.h

+ 2 - 0
Libraries/LibGUI/Window.cpp

@@ -94,6 +94,8 @@ Window::~Window()
 void Window::close()
 void Window::close()
 {
 {
     hide();
     hide();
+    if (on_close)
+        on_close();
 }
 }
 
 
 void Window::move_to_front()
 void Window::move_to_front()

+ 1 - 0
Libraries/LibGUI/Window.h

@@ -84,6 +84,7 @@ public:
         Close,
         Close,
     };
     };
 
 
+    Function<void()> on_close;
     Function<CloseRequestDecision()> on_close_request;
     Function<CloseRequestDecision()> on_close_request;
     Function<void(bool is_active_input)> on_active_input_change;
     Function<void(bool is_active_input)> on_active_input_change;
     Function<void(const bool is_active)> on_activity_change;
     Function<void(const bool is_active)> on_activity_change;