]> git.saurik.com Git - wxWidgets.git/commitdiff
set focus to the control when it's clicked
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 4 Apr 2008 23:07:55 +0000 (23:07 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 4 Apr 2008 23:07:55 +0000 (23:07 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53014 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/calctrl.h
src/generic/calctrlg.cpp
src/msw/calctrl.cpp

index 5f752cb1c05b0fa11b2ce787d8685497ea09533e..50df43095ed358c7a505943db926df0de4b40804 100644 (file)
@@ -59,6 +59,7 @@ protected:
 
     virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
 
+    void MSWOnClick(wxMouseEvent& event);
     void MSWOnDoubleClick(wxMouseEvent& event);
 
 private:
index c52a74808ae554f43c51a7e0c75042d687c4c2e3..20b693df3ff21df44b539866acb09d8a60cdda0e 100644 (file)
@@ -1500,6 +1500,10 @@ void wxGenericCalendarCtrl::OnClick(wxMouseEvent& event)
             event.Skip();
             break;
     }
+
+    // as we don't (always) skip the message, we're not going to receive the
+    // focus on click by default if we don't do it ourselves
+    SetFocus();
 }
 
 wxCalendarHitTestResult wxGenericCalendarCtrl::HitTest(const wxPoint& pos,
index 4a4c4d9ede388d047c251862565e84b65f466caa..8a10681823b74063f47ff487aeafe286b3ed3842 100644 (file)
@@ -97,6 +97,8 @@ wxCalendarCtrl::Create(wxWindow *parent,
 
     UpdateMarks();
 
+    Connect(wxEVT_LEFT_DOWN,
+            wxMouseEventHandler(wxCalendarCtrl::MSWOnClick));
     Connect(wxEVT_LEFT_DCLICK,
             wxMouseEventHandler(wxCalendarCtrl::MSWOnDoubleClick));
 
@@ -400,4 +402,13 @@ void wxCalendarCtrl::MSWOnDoubleClick(wxMouseEvent& event)
     event.Skip();
 }
 
+void wxCalendarCtrl::MSWOnClick(wxMouseEvent& event)
+{
+    // for some reason, the control doesn't get focus on its own when the user
+    // clicks in it
+    SetFocus();
+
+    event.Skip();
+}
+
 #endif // wxUSE_CALENDARCTRL