diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-12-03 21:08:49 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-12-09 22:14:48 +0100 |
commit | ca0cd6985adc7b321b9bc4affe79c4f26eab1722 (patch) | |
tree | 41c6ec5a704b015311556e92d4c243a4d7470430 /vcl | |
parent | 975a1934994ab1e7e5f2ac890f00159c73546a61 (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/64492
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 043c2f39bfd5f70885dede547cb3c3b78ed8c5b9)
Reviewed-on: https://gerrit.libreoffice.org/64619
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/dialog.cxx | 37 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 2 |
2 files changed, 38 insertions, 1 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index b20ac608762a..285b7c21da15 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -1423,6 +1423,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 7ee56d5158ab..516155f79ebd 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -2231,7 +2231,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: |