Fix Tab navigation when focused control is disabled.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2010-08-01 10:11:53 +00:00
parent ce5abbf9f5
commit 0826c4d39a
4 changed files with 19 additions and 5 deletions

View File

@@ -590,6 +590,8 @@ protected:
int& x, int& y, int& x, int& y,
int& w, int& h) const; int& w, int& h) const;
bool MSWEnableHWND(WXHWND hWnd, bool enable);
private: private:
// common part of all ctors // common part of all ctors
void Init(); void Init();

View File

@@ -403,7 +403,7 @@ bool wxRadioBox::Enable(unsigned int item, bool enable)
wxCHECK_MSG( IsValid(item), false, wxCHECK_MSG( IsValid(item), false,
wxT("invalid item in wxRadioBox::Enable()") ); wxT("invalid item in wxRadioBox::Enable()") );
BOOL ret = ::EnableWindow((*m_radioButtons)[item], enable); BOOL ret = MSWEnableHWND((*m_radioButtons)[item], enable);
return (ret == 0) != enable; return (ret == 0) != enable;
} }

View File

@@ -625,7 +625,7 @@ bool wxSpinCtrl::Enable(bool enable)
return false; return false;
} }
::EnableWindow(GetBuddyHwnd(), enable); MSWEnableHWND(GetBuddyHwnd(), enable);
return true; return true;
} }

View File

@@ -699,9 +699,21 @@ wxWindow *wxWindowBase::DoFindFocus()
void wxWindowMSW::DoEnable( bool enable ) void wxWindowMSW::DoEnable( bool enable )
{ {
HWND hWnd = GetHwnd(); MSWEnableHWND(GetHwnd(), enable);
if ( hWnd ) }
::EnableWindow(hWnd, (BOOL)enable);
bool wxWindowMSW::MSWEnableHWND(WXHWND hWnd, bool enable)
{
if ( !hWnd )
return false;
// If disabling focused control, we move focus to the next one, as if the
// user pressed Tab. That's because we can't keep focus on a disabled
// control, Tab-navigation would stop working then.
if ( !enable && ::GetFocus() == hWnd )
Navigate();
return ::EnableWindow(hWnd, (BOOL)enable);
} }
bool wxWindowMSW::Show(bool show) bool wxWindowMSW::Show(bool show)