Kaydet (Commit) 043c2f39 authored tarafından Caolán McNamara's avatar Caolán McNamara

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: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 83afe755
...@@ -179,6 +179,7 @@ public: ...@@ -179,6 +179,7 @@ public:
void add_button(PushButton* pButton, int nResponse, bool bTransferOwnership); void add_button(PushButton* pButton, int nResponse, bool bTransferOwnership);
void set_default_response(int nResponse); void set_default_response(int nResponse);
int get_default_response();
vcl::Window* get_widget_for_response(int nResponse); vcl::Window* get_widget_for_response(int nResponse);
}; };
......
...@@ -1437,6 +1437,43 @@ vcl::Window* Dialog::get_widget_for_response(int response) ...@@ -1437,6 +1437,43 @@ vcl::Window* Dialog::get_widget_for_response(int response)
return nullptr; 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) void Dialog::set_default_response(int response)
{ {
//copy explicit responses //copy explicit responses
......
...@@ -2231,7 +2231,7 @@ void MessageDialog::create_message_area() ...@@ -2231,7 +2231,7 @@ void MessageDialog::create_message_area()
assert(pButtonBox); assert(pButtonBox);
VclPtr<PushButton> pBtn; VclPtr<PushButton> pBtn;
short nDefaultResponse = RET_CANCEL; short nDefaultResponse = get_default_response();
switch (m_eButtonsType) switch (m_eButtonsType)
{ {
case VclButtonsType::NONE: case VclButtonsType::NONE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment