]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxWindow::HasFocus() for more convenient way of determining if a (possibly...
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 21 Jan 2008 13:30:24 +0000 (13:30 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 21 Jan 2008 13:30:24 +0000 (13:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51308 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/window.tex
include/wx/window.h
src/common/wincmn.cpp

index 564e8e5b1299dca1824529cfb05773f34c0f20c1..d84184c0eb6ce650ec5cc09f30d19cd137cbf57a 100644 (file)
@@ -276,6 +276,7 @@ All (GUI):
   Also made it easier to derive from wxWizard and override behaviour.
 - Made wxSizer::Fit() set the client size of the target window
 - Add support for wxDatePickerCtrl in wxGenericValidator (Herry Ayen Yang)
+- Added wxWindow::HasFocus().
 
 wxGTK:
 
index d7796285d0d31981cf0c7ddf16a35f82868b424a..48c53a7b4d4f3f8ee7671280915e212c83e248da 100644 (file)
@@ -624,7 +624,8 @@ Note that this is a static function, so it can be called without needing a wxWin
 
 \wxheading{See also}
 
-\helpref{wxWindow::SetFocus}{wxwindowsetfocus}
+\helpref{wxWindow::SetFocus}{wxwindowsetfocus},
+\helpref{wxWindow::HasFocus}{wxwindowhasfocus}
 
 
 
@@ -1556,6 +1557,18 @@ extra styles.
 Returns \texttt{true} if the window has the given \arg{flag} bit set.
 
 
+\membersection{wxWindow::HasFocus}\label{wxwindowhasfocus}
+
+\constfunc{virtual bool}{HasFocus}{\void}
+
+Returns \true if the window (or in case of composite controls, its main
+child window) has focus.
+
+\wxheading{See also}
+
+\helpref{FindFocus}{wxwindowfindfocus}
+
+
 \membersection{wxWindow::HasMultiplePages}\label{wxwindowhasmultiplepages}
 
 \constfunc{virtual bool}{HasMultiplePages}{\void}
@@ -3083,8 +3096,9 @@ This sets the window to receive keyboard input.
 
 \wxheading{See also}
 
-\helpref{wxFocusEvent}{wxfocusevent}
-\helpref{wxPanel::SetFocus}{wxpanelsetfocus}
+\helpref{HasFocus}{wxwindowhasfocus},
+\helpref{wxFocusEvent}{wxfocusevent},
+\helpref{wxPanel::SetFocus}{wxpanelsetfocus},
 \helpref{wxPanel::SetFocusIgnoringChildren}{wxpanelsetfocusignoringchildren}
 
 
index e1fb16519b455ba44b43add13ee764c07f33f7bb..013426c8f80e1877375d33536654f199091830d7 100644 (file)
@@ -620,6 +620,11 @@ public:
 
     static wxWindow *DoFindFocus() /* = 0: implement in derived classes */;
 
+        // return true if the window has focus (handles composite windows
+        // correctly - returns true if GetMainWindowOfCompositeControl()
+        // has focus)
+    virtual bool HasFocus() const;
+
         // can this window have focus in principle?
         //
         // the difference between AcceptsFocus[FromKeyboard]() and CanAcceptFocus
index 477c4d8c9d6473256520cc0b8682fbbf788202c1..b114571d5d7fc78593c2f5e56c500e7de590e5b1 100644 (file)
@@ -2733,6 +2733,13 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, WindowOrder move)
     return win ? win->GetMainWindowOfCompositeControl() : NULL;
 }
 
+bool wxWindowBase::HasFocus() const
+{
+    wxWindowBase *win = DoFindFocus();
+    return win == this ||
+           win == wxConstCast(this, wxWindowBase)->GetMainWindowOfCompositeControl();
+}
+
 // ----------------------------------------------------------------------------
 // global functions
 // ----------------------------------------------------------------------------