From 644ca26af744aec1e66c8dd4199d1228e0f780be Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 14 May 2019 21:50:36 +0100 Subject: allow closing welded dialogs to be cancelled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit from both directions of window manager close button and esc Change-Id: I3c7bd6f67e3100f5dd3ab04456ad9aa5100c472c Reviewed-on: https://gerrit.libreoffice.org/72319 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/source/window/dialog.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'vcl/source') diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 21957995644e..5348e206f2c0 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -835,8 +835,26 @@ bool Dialog::Close() if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() && !IsInExecute() ) return false; + // If there's a cancel button with a custom handler, then always give it a chance to + // handle Dialog::Close + PushButton* pCustomCancelButton; + PushButton* pCancelButton = dynamic_cast(get_widget_for_response(RET_CANCEL)); + if (!mbInClose && pCancelButton && pCancelButton->GetClickHdl().IsSet()) + pCustomCancelButton = pCancelButton; + else + pCustomCancelButton = nullptr; + mbInClose = true; + if (pCustomCancelButton) + { + pCustomCancelButton->Click(); + if (xWindow->IsDisposed()) + return true; + mbInClose = false; + return false; + } + if ( !(GetStyle() & WB_CLOSEABLE) ) { bool bRet = true; -- cgit