diff --git a/docs/changes.txt b/docs/changes.txt index 7b035c2af8..8096ca01ec 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -620,6 +620,7 @@ wxMSW: - Fix wxClientDC::Clear() for scrolled windows (Artur Wieczorek). - Make wxPrinterDC::DrawIcon() actually work (Artur Wieczorek). - Fix handling of wxSET, wxCLEAR and wxINVERT in wxDC (Artur Wieczorek). +- Fix bug with multiple default buttons in a dialog (Artur Wieczorek). wxOSX: 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 */