mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
Add NativeWindowObserver::OnCloseButtonClicked
This commit is contained in:
@@ -243,6 +243,14 @@ void BrowserWindow::WillDestroyNativeObject() {
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) {
|
||||
// When user tries to close the window by clicking the close button, we do
|
||||
// not close the window immediately, instead we try to close the web page
|
||||
// first, and when the web page is closed the window will also be closed.
|
||||
*prevent_default = true;
|
||||
window_->RequestToClosePage();
|
||||
}
|
||||
|
||||
void BrowserWindow::OnWindowClosed() {
|
||||
api_web_contents_->DestroyWebContents(true /* async */);
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ class BrowserWindow : public mate::TrackableObject<BrowserWindow>,
|
||||
// NativeWindowObserver:
|
||||
void WillCloseWindow(bool* prevent_default) override;
|
||||
void WillDestroyNativeObject() override;
|
||||
void OnCloseButtonClicked(bool* prevent_default) override;
|
||||
void OnWindowClosed() override;
|
||||
void OnWindowEndSession() override;
|
||||
void OnWindowBlur() override;
|
||||
|
||||
Reference in New Issue
Block a user