Fix bug with TAB being able to switch focus between MDI frames.

The keyboard navigation code correctly checked that TAB was not propagated
above the TLW containing the window in which the key was pressed to avoid
switching focus between different TLWs by pressing TAB.

However wxMDIChildFrame is not a TLW and so it was possible to switch focus
between two different MDI child frames by pressing TAB. This was unexpected
and counterintuitive, especially because the frame receiving focus was not
even activated (which might be another bug).

Fix this by adding a new wxWindow::IsTopNavigationDomain() virtual method that
can be overridden to indicate that a window is a self-contained "keyboard
navigation domain" and that keyboard events shouldn't propagate outside of it
and override it in both wxTopLevelWindow and wxMDIChildFrame to ensure that it
behaves correctly.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68502 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-08-03 00:45:42 +00:00
parent 2a0777a8f0
commit 6e92c2991b
4 changed files with 20 additions and 2 deletions

View File

@@ -1422,6 +1422,15 @@ public:
virtual wxWindow *GetMainWindowOfCompositeControl()
{ return (wxWindow*)this; }
// If this function returns true, keyboard navigation events shouldn't
// escape from it. A typical example of such "navigation domain" is a top
// level window because pressing TAB in one of them must not transfer focus
// to a different top level window. But it's not limited to them, e.g. MDI
// children frames are not top level windows (and their IsTopLevel()
// returns false) but still are self-contained navigation domains as well.
virtual bool IsTopNavigationDomain() const { return false; }
protected:
// helper for the derived class Create() methods: the first overload, with
// validator parameter, should be used for child windows while the second