CanAcceptFocus() now returns true if either the window itself or one of its children accepts focus; added new IsFocusable() to test whether the window itself accepts focus

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46994 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-06-28 12:04:06 +00:00
parent 4e21a649f0
commit edc0987174
6 changed files with 52 additions and 27 deletions

View File

@@ -582,17 +582,35 @@ public:
// this class clients and take into account the current window state
virtual bool AcceptsFocus() const { return true; }
// can this window have focus right now?
bool CanAcceptFocus() const { return AcceptsFocus() && IsShown() && IsEnabled(); }
// can this window or one of its children accept focus?
//
// usually it's the same as AcceptsFocus() but is overridden for
// container windows
virtual bool AcceptsFocusRecursively() const { return AcceptsFocus(); }
// can this window be given focus by keyboard navigation? if not, the
// only way to give it focus (provided it accepts it at all) is to
// click it
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 itself have focus?
bool IsFocusable() const { return AcceptsFocus() && CanBeFocused(); }
// can this window have focus right now?
//
// if this method returns true, it means that calling SetFocus() will
// put focus either to this window or one of its children, if you need
// to know whether this window accepts focus itself, use IsFocusable()
bool CanAcceptFocus() const
{ return AcceptsFocusRecursively() && CanBeFocused(); }
// can this window be assigned focus from keyboard right now?
bool CanAcceptFocusFromKeyboard() const
{ return AcceptsFocusFromKeyboard() && CanAcceptFocus(); }
{ return AcceptsFocusFromKeyboard() && CanBeFocused(); }
// call this when the return value of AcceptsFocus() changes
virtual void SetCanFocus(bool WXUNUSED(canFocus)) { }