From 4427c0a3ff15545c46f97a217a1dc947099d4a40 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 27 Oct 2006 18:02:21 +0000 Subject: [PATCH] [ 1585858 ] Fix wxDatePickerCtrlGeneric and wxComboCtrl kb navigation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/combo.h | 9 +++++++++ include/wx/generic/datectrl.h | 1 + src/common/combocmn.cpp | 10 ++++++++-- src/generic/datectlg.cpp | 9 +++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/wx/combo.h b/include/wx/combo.h index e8704a4f66..a504c1543e 100644 --- a/include/wx/combo.h +++ b/include/wx/combo.h @@ -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). diff --git a/include/wx/generic/datectrl.h b/include/wx/generic/datectrl.h index 642a693647..e6b97d405d 100644 --- a/include/wx/generic/datectrl.h +++ b/include/wx/generic/datectrl.h @@ -76,6 +76,7 @@ private: void OnText(wxCommandEvent &event); void OnSize(wxSizeEvent& event); + void OnFocus(wxFocusEvent& event); wxCalendarCtrl *m_cal; wxComboCtrl* m_combo; diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index bcfbb96bfd..e069544404 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -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; } diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 9c6bd88b3a..7648284451 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -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 -- 2.47.2