Fix tab navigation bug with radio boxes without enabled items.

There was a bug similar to the one in the preceding commit with radio boxes
under wxMSW too: if all radio box buttons were disabled (or hidden, although
this should be much more rare in practice, unlike the disabled case which was
deemed to be rare in r74583 commit message but turned out to actually happen),
the radio box still pretended to accept focus but didn't really do it.

Fix this by allowing to override wxWindow::CanBeFocused() and do it in
wxRadioBox to check whether we have any enabled visible items.

Also add a check for CanBeFocused() to wxControlContainer code.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74586 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-07-23 12:44:33 +00:00
parent dee22e3198
commit bd6ca54f63
4 changed files with 30 additions and 4 deletions

View File

@@ -724,8 +724,13 @@ public:
virtual bool AcceptsFocusFromKeyboard() const { return AcceptsFocus(); }
// this is mostly a helper for the various functions using it below
bool CanBeFocused() const { return IsShown() && IsEnabled(); }
// Can this window be focused right now, in its current state? This
// shouldn't be called at all if AcceptsFocus() returns false.
//
// It is a convenient helper for the various functions using it below
// but also a hook allowing to override the default logic for some rare
// cases (currently just wxRadioBox in wxMSW) when it's inappropriate.
virtual bool CanBeFocused() const { return IsShown() && IsEnabled(); }
// can this window itself have focus?
bool IsFocusable() const { return AcceptsFocus() && CanBeFocused(); }