summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-12-03 21:08:49 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-12-04 09:50:46 +0100
commita9296c2c5527c24c498cc6c5459463330cd78bd4 (patch)
treea64ee27a829b3cd87519fd9f4dd8acdeb6dc79ee
parent7615df756179771225964174c4a06e95284d0bda (diff)
Resolves: tdf#120977 intended default button overridden
for those cases where the built-in buttons are not inserted Change-Id: Ibb091832c097a15dc22a7994d94f8db6a4e47520 Reviewed-on: https://gerrit.libreoffice.org/64491 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/vcl/dialog.hxx1
-rw-r--r--vcl/source/window/dialog.cxx37
-rw-r--r--vcl/source/window/layout.cxx2
3 files changed, 39 insertions, 1 deletions
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 96690febcad5..2b3b1f29f2e6 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -179,6 +179,7 @@ public:
void add_button(PushButton* pButton, int nResponse, bool bTransferOwnership);
void set_default_response(int nResponse);
+ int get_default_response();
vcl::Window* get_widget_for_response(int nResponse);
};
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index dc19e56c5738..0d371e4641dc 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1437,6 +1437,43 @@ vcl::Window* Dialog::get_widget_for_response(int response)
return nullptr;
}
+int Dialog::get_default_response()
+{
+ //copy explicit responses
+ std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
+
+ //add implicit responses
+ for (vcl::Window* pChild = mpActionArea->GetWindow(GetWindowType::FirstChild); pChild;
+ pChild = pChild->GetWindow(GetWindowType::Next))
+ {
+ if (aResponses.find(pChild) != aResponses.end())
+ continue;
+ switch (pChild->GetType())
+ {
+ case WindowType::OKBUTTON:
+ aResponses[pChild] = RET_OK;
+ break;
+ case WindowType::CANCELBUTTON:
+ aResponses[pChild] = RET_CANCEL;
+ break;
+ case WindowType::HELPBUTTON:
+ aResponses[pChild] = RET_HELP;
+ break;
+ default:
+ break;
+ }
+ }
+
+ for (auto& a : aResponses)
+ {
+ if (a.first->GetStyle() & WB_DEFBUTTON)
+ {
+ return a.second;
+ }
+ }
+ return RET_CANCEL;
+}
+
void Dialog::set_default_response(int response)
{
//copy explicit responses
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 6e8acdf41d51..91de02405af6 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -2232,7 +2232,7 @@ void MessageDialog::create_message_area()
assert(pButtonBox);
VclPtr<PushButton> pBtn;
- short nDefaultResponse = RET_CANCEL;
+ short nDefaultResponse = get_default_response();
switch (m_eButtonsType)
{
case VclButtonsType::NONE: