]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1585858 ] Fix wxDatePickerCtrlGeneric and wxComboCtrl kb navigation
authorRobert Roebling <robert@roebling.de>
Fri, 27 Oct 2006 18:02:21 +0000 (18:02 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 27 Oct 2006 18:02:21 +0000 (18:02 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/combo.h
include/wx/generic/datectrl.h
src/common/combocmn.cpp
src/generic/datectlg.cpp

index e8704a4f665589d8831c956c137f2c06d589486b..a504c1543e49fc969a2fff247483d022b48b1ecb 100644 (file)
@@ -394,6 +394,9 @@ public:
 
     wxByte GetPopupWindowState() const { return m_popupWinState; }
 
+    // Set value returned by GetMainWindowOfCompositeControl
+    void SetCtrlMainWnd( wxWindow* wnd ) { m_mainCtrlWnd = wnd; }
+
 protected:
 
     //
@@ -492,6 +495,9 @@ protected:
     virtual void DoSetToolTip( wxToolTip *tip );
 #endif
 
+    virtual wxWindow *GetMainWindowOfCompositeControl()
+        { return m_mainCtrlWnd; }
+
     // This is used when m_text is hidden (readonly).
     wxString                m_valueString;
 
@@ -520,6 +526,9 @@ protected:
     // this is for the popup window
     wxEvtHandler*           m_popupWinEvtHandler;
 
+    // main (ie. topmost) window of a composite control (default = this)
+    wxWindow*               m_mainCtrlWnd;
+
     // used to prevent immediate re-popupping incase closed popup
     // by clicking on the combo control (needed because of inconsistent
     // transient implementation across platforms).
index 642a6936476081c3e807b00107cac8afabb1f8c7..e6b97d405d41823cac3cd70f120f2bfd0593b4cc 100644 (file)
@@ -76,6 +76,7 @@ private:
 
     void OnText(wxCommandEvent &event);
     void OnSize(wxSizeEvent& event);
+    void OnFocus(wxFocusEvent& event);
 
     wxCalendarCtrl *m_cal;
     wxComboCtrl* m_combo;
index bcfbb96bfdbcc9ef10c706647d8d8fffb5f681d0..e0695444048dec1ba7fe9bf63dac6ebc1309c516 100644 (file)
@@ -732,6 +732,8 @@ void wxComboCtrlBase::Init()
     m_toplevEvtHandler = (wxEvtHandler*) NULL;
 #endif
 
+    m_mainCtrlWnd = this;
+
     m_heightPopup = -1;
     m_widthMinPopup = -1;
     m_anchorSide = 0;
@@ -1537,11 +1539,15 @@ void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event)
         if ( keycode == WXK_TAB )
         {
             wxNavigationKeyEvent evt;
+
+            wxWindow* mainCtrl = GetMainWindowOfCompositeControl();
+
             evt.SetFlags(wxNavigationKeyEvent::FromTab|
                          (!event.ShiftDown() ? wxNavigationKeyEvent::IsForward
                                              : wxNavigationKeyEvent::IsBackward));
-            evt.SetEventObject(this);
-            GetParent()->GetEventHandler()->AddPendingEvent(evt);
+            evt.SetEventObject(mainCtrl);
+            evt.SetCurrentFocus(mainCtrl);
+            mainCtrl->GetParent()->GetEventHandler()->AddPendingEvent(evt);
             return;
         }
 
index 9c6bd88b3a3b3e60eaa61cea8a139bbd44d2041f..7648284451e3f69aaed31bdde8430cd00d3be375 100644 (file)
@@ -370,6 +370,7 @@ END_EVENT_TABLE()
 BEGIN_EVENT_TABLE(wxDatePickerCtrlGeneric, wxDatePickerCtrlBase)
     EVT_TEXT(wxID_ANY, wxDatePickerCtrlGeneric::OnText)
     EVT_SIZE(wxDatePickerCtrlGeneric::OnSize)
+    EVT_SET_FOCUS(wxDatePickerCtrlGeneric::OnFocus)
 END_EVENT_TABLE()
 
 #ifndef wxHAS_NATIVE_DATEPICKCTRL
@@ -404,6 +405,8 @@ bool wxDatePickerCtrlGeneric::Create(wxWindow *parent,
     m_combo = new wxComboCtrl(this, -1, wxEmptyString,
                               wxDefaultPosition, wxDefaultSize);
 
+    m_combo->SetCtrlMainWnd(this);
+
     m_popup = new wxCalendarComboPopup();
 
 #if defined(__WXMSW__)
@@ -524,6 +527,12 @@ void wxDatePickerCtrlGeneric::OnText(wxCommandEvent &ev)
 }
 
 
+void wxDatePickerCtrlGeneric::OnFocus(wxFocusEvent& WXUNUSED(event))
+{
+    m_combo->SetFocus();
+}
+
+
 #endif // wxUSE_DATEPICKCTRL_GENERIC
 
 #endif // wxUSE_DATEPICKCTRL