[ 1585858 ] Fix wxDatePickerCtrlGeneric and wxComboCtrl kb navigation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-10-27 18:02:21 +00:00
parent 34e2d9439b
commit 4427c0a3ff
4 changed files with 27 additions and 2 deletions

View File

@@ -394,6 +394,9 @@ public:
wxByte GetPopupWindowState() const { return m_popupWinState; } wxByte GetPopupWindowState() const { return m_popupWinState; }
// Set value returned by GetMainWindowOfCompositeControl
void SetCtrlMainWnd( wxWindow* wnd ) { m_mainCtrlWnd = wnd; }
protected: protected:
// //
@@ -492,6 +495,9 @@ protected:
virtual void DoSetToolTip( wxToolTip *tip ); virtual void DoSetToolTip( wxToolTip *tip );
#endif #endif
virtual wxWindow *GetMainWindowOfCompositeControl()
{ return m_mainCtrlWnd; }
// This is used when m_text is hidden (readonly). // This is used when m_text is hidden (readonly).
wxString m_valueString; wxString m_valueString;
@@ -520,6 +526,9 @@ protected:
// this is for the popup window // this is for the popup window
wxEvtHandler* m_popupWinEvtHandler; 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 // used to prevent immediate re-popupping incase closed popup
// by clicking on the combo control (needed because of inconsistent // by clicking on the combo control (needed because of inconsistent
// transient implementation across platforms). // transient implementation across platforms).

View File

@@ -76,6 +76,7 @@ private:
void OnText(wxCommandEvent &event); void OnText(wxCommandEvent &event);
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
void OnFocus(wxFocusEvent& event);
wxCalendarCtrl *m_cal; wxCalendarCtrl *m_cal;
wxComboCtrl* m_combo; wxComboCtrl* m_combo;

View File

@@ -732,6 +732,8 @@ void wxComboCtrlBase::Init()
m_toplevEvtHandler = (wxEvtHandler*) NULL; m_toplevEvtHandler = (wxEvtHandler*) NULL;
#endif #endif
m_mainCtrlWnd = this;
m_heightPopup = -1; m_heightPopup = -1;
m_widthMinPopup = -1; m_widthMinPopup = -1;
m_anchorSide = 0; m_anchorSide = 0;
@@ -1537,11 +1539,15 @@ void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event)
if ( keycode == WXK_TAB ) if ( keycode == WXK_TAB )
{ {
wxNavigationKeyEvent evt; wxNavigationKeyEvent evt;
wxWindow* mainCtrl = GetMainWindowOfCompositeControl();
evt.SetFlags(wxNavigationKeyEvent::FromTab| evt.SetFlags(wxNavigationKeyEvent::FromTab|
(!event.ShiftDown() ? wxNavigationKeyEvent::IsForward (!event.ShiftDown() ? wxNavigationKeyEvent::IsForward
: wxNavigationKeyEvent::IsBackward)); : wxNavigationKeyEvent::IsBackward));
evt.SetEventObject(this); evt.SetEventObject(mainCtrl);
GetParent()->GetEventHandler()->AddPendingEvent(evt); evt.SetCurrentFocus(mainCtrl);
mainCtrl->GetParent()->GetEventHandler()->AddPendingEvent(evt);
return; return;
} }

View File

@@ -370,6 +370,7 @@ END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxDatePickerCtrlGeneric, wxDatePickerCtrlBase) BEGIN_EVENT_TABLE(wxDatePickerCtrlGeneric, wxDatePickerCtrlBase)
EVT_TEXT(wxID_ANY, wxDatePickerCtrlGeneric::OnText) EVT_TEXT(wxID_ANY, wxDatePickerCtrlGeneric::OnText)
EVT_SIZE(wxDatePickerCtrlGeneric::OnSize) EVT_SIZE(wxDatePickerCtrlGeneric::OnSize)
EVT_SET_FOCUS(wxDatePickerCtrlGeneric::OnFocus)
END_EVENT_TABLE() END_EVENT_TABLE()
#ifndef wxHAS_NATIVE_DATEPICKCTRL #ifndef wxHAS_NATIVE_DATEPICKCTRL
@@ -404,6 +405,8 @@ bool wxDatePickerCtrlGeneric::Create(wxWindow *parent,
m_combo = new wxComboCtrl(this, -1, wxEmptyString, m_combo = new wxComboCtrl(this, -1, wxEmptyString,
wxDefaultPosition, wxDefaultSize); wxDefaultPosition, wxDefaultSize);
m_combo->SetCtrlMainWnd(this);
m_popup = new wxCalendarComboPopup(); m_popup = new wxCalendarComboPopup();
#if defined(__WXMSW__) #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_GENERIC
#endif // wxUSE_DATEPICKCTRL #endif // wxUSE_DATEPICKCTRL