summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-05-14 21:50:36 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-05-17 10:59:44 +0200
commit644ca26af744aec1e66c8dd4199d1228e0f780be (patch)
tree2a364e77b595a65b9f29ce076b5b9352c9ccdbea /vcl/source
parentdc17f247daeb281dda531ff335873d563db5b653 (diff)
allow closing welded dialogs to be cancelled
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 <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/window/dialog.cxx18
1 files changed, 18 insertions, 0 deletions
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<PushButton*>(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;