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:
@@ -576,6 +576,14 @@ public:
|
||||
// Return true if the button was clicked, false otherwise.
|
||||
static bool MSWClickButtonIfPossible(wxButton* btn);
|
||||
|
||||
// This method is used for handling wxRadioButton-related complications,
|
||||
// see wxRadioButton::SetValue(). It calls WXDoUpdatePendingFocus() for
|
||||
// this window and all its parents up to the enclosing TLW, recursively.
|
||||
void WXSetPendingFocus(wxWindow* win);
|
||||
|
||||
// Should be overridden by all classes storing the "last focused" window.
|
||||
virtual void WXDoUpdatePendingFocus(wxWindow* WXUNUSED(win)) {}
|
||||
|
||||
protected:
|
||||
// this allows you to implement standard control borders without
|
||||
// repeating the code in different classes that are not derived from
|
||||
|
Reference in New Issue
Block a user