Fix bug with wxRadioButton state changing unexpectedly in wxMSW
In wxMSW, a focused wxRadioButton is always checked, which meant that checking a wxRadioButton while focus was not in the window containing it and later giving the focus to that window could uncheck it by giving focus to another wxRadioButton that had had it previously. Fix this by adding WXSetPendingFocus() to wxMSW wxWindow and calling it from wxRadioButton::SetValue() to ensure that when the focus is regained, it goes to the newly checked radio button and not some other one. This replaces the previously used, for the same purpose, wxMSW-specific wxTopLevelWindow::SetLastFocus(), so while this solution is not exactly pretty, it's not worse than we had before, while being more generic. Also add a unit test checking that things work correctly in the scenario described above. Closes https://github.com/wxWidgets/wxWidgets/pull/1257 Closes #18341.
This commit is contained in:
@@ -266,6 +266,12 @@ public:
|
||||
{
|
||||
return m_container.HasTransparentBackground();
|
||||
}
|
||||
|
||||
WXDLLIMPEXP_INLINE_CORE
|
||||
virtual void WXDoUpdatePendingFocus(wxWindow* win) wxOVERRIDE
|
||||
{
|
||||
return m_container.SetLastFocus(win);
|
||||
}
|
||||
#endif // __WXMSW__
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user