Fix a bug which could result in two default buttons in wxMSW dialogs.

Exchange the order of setting/resetting the new/old button as the default one
when focus is lost/gained to avoid the possibility of having two simultaneously
default buttons at once.

Closes #9528.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-01-29 22:26:00 +00:00
parent 3ded9e191d
commit 67fe66530d

View File

@@ -284,8 +284,11 @@ void wxButton::SetTmpDefault()
wxWindow *winOldDefault = tlw->GetDefaultItem();
tlw->SetTmpDefaultItem(this);
SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), false);
// Notice that the order of these statements is important, the old button
// is not reset if we do it the other way round, probably because of
// something done by the default DM_SETDEFID handler.
SetDefaultStyle(this, true);
SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), false);
}
// unset this button as currently default, it may still stay permanent default
@@ -299,8 +302,9 @@ void wxButton::UnsetTmpDefault()
wxWindow *winOldDefault = tlw->GetDefaultItem();
SetDefaultStyle(this, false);
// Just as in SetTmpDefault() above, the order is important here.
SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), true);
SetDefaultStyle(this, false);
}
/* static */