Fix completely broken default button handling in wxMSW
The logic in wxButton::{Set,Unset}TmpDefault() didn't work at all when the temporary button was the same as the permanent default button as the code made the same button non-default immediately after making it default (or vice versa). In particular, this ensured that default button was never highlighted correctly (at least after the first focus change) in dialogs containing a single button only. Fix this by simply skipping modification of the old default button if it was the same one as the new default button.
This commit is contained in:
@@ -172,6 +172,7 @@ wxMSW:
|
|||||||
- Fix wxScreenDC::GetSize() with multiple monitors (iwbnwif).
|
- Fix wxScreenDC::GetSize() with multiple monitors (iwbnwif).
|
||||||
- Fix background colour returned by wxTextCtrl::GetStyle() (Andreas Falkenhahn).
|
- Fix background colour returned by wxTextCtrl::GetStyle() (Andreas Falkenhahn).
|
||||||
- Revert to using equally-sized buttons in wxToolBar by default.
|
- 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.
|
- Restore dispatching wxThreadEvent while resizing the window broken in 3.1.0.
|
||||||
- Fix wxGraphicsMatrix::TransformDistance for Direct2D renderer.
|
- Fix wxGraphicsMatrix::TransformDistance for Direct2D renderer.
|
||||||
- Fix wxDC::Clear() for rotated DC.
|
- Fix wxDC::Clear() for rotated DC.
|
||||||
|
@@ -284,13 +284,19 @@ void wxButton::SetTmpDefault()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wxWindow *winOldDefault = tlw->GetDefaultItem();
|
wxWindow *winOldDefault = tlw->GetDefaultItem();
|
||||||
|
|
||||||
tlw->SetTmpDefaultItem(this);
|
tlw->SetTmpDefaultItem(this);
|
||||||
|
|
||||||
// Notice that the order of these statements is important, the old button
|
// 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
|
// is not reset if we do it the other way round, probably because of
|
||||||
// something done by the default DM_SETDEFID handler.
|
// something done by the default DM_SETDEFID handler.
|
||||||
SetDefaultStyle(this, true);
|
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
|
// 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.
|
// Just as in SetTmpDefault() above, the order is important here.
|
||||||
SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), true);
|
SetDefaultStyle(wxDynamicCast(winOldDefault, wxButton), true);
|
||||||
SetDefaultStyle(this, false);
|
if ( winOldDefault != this )
|
||||||
|
{
|
||||||
|
SetDefaultStyle(this, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
Reference in New Issue
Block a user