summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 8c952c9b668a..e9a257378d34 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -180,6 +180,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 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: