From 67fe66530df03573df553cf6b0037db213ef6902 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 29 Jan 2014 22:26:00 +0000 Subject: [PATCH] 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 --- src/msw/button.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 33beb43256..c7c463261d 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -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 */