diff --git a/docs/changes.txt b/docs/changes.txt index a5c7193af4..95328979ae 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -172,6 +172,7 @@ wxMSW: - Fix wxScreenDC::GetSize() with multiple monitors (iwbnwif). - Fix background colour returned by wxTextCtrl::GetStyle() (Andreas Falkenhahn). - Revert to using equally-sized buttons in wxToolBar by default. +- Fix default button highlighting. - Restore dispatching wxThreadEvent while resizing the window broken in 3.1.0. - Fix wxGraphicsMatrix::TransformDistance for Direct2D renderer. - Fix wxDC::Clear() for rotated DC. diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 1d934ee94d..8211259dcb 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -284,13 +284,19 @@ void wxButton::SetTmpDefault() return; wxWindow *winOldDefault = tlw->GetDefaultItem(); + tlw->SetTmpDefaultItem(this); // 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); + if ( winOldDefault != this ) + { + // But we mustn't reset the default style on this button itself if it + // had already been the default. + SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), false); + } } // unset this button as currently default, it may still stay permanent default @@ -306,7 +312,10 @@ void wxButton::UnsetTmpDefault() // Just as in SetTmpDefault() above, the order is important here. SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), true); - SetDefaultStyle(this, false); + if ( winOldDefault != this ) + { + SetDefaultStyle(this, false); + } } /* static */