diff --git a/include/wx/generic/srchctlg.h b/include/wx/generic/srchctlg.h index f1d186b751..37f59df29d 100644 --- a/include/wx/generic/srchctlg.h +++ b/include/wx/generic/srchctlg.h @@ -169,6 +169,7 @@ protected: private: friend class wxSearchButton; + friend class wxSearchTextCtrl; #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // Implement wxMSW-specific pure virtual function by forwarding it to the diff --git a/interface/wx/srchctrl.h b/interface/wx/srchctrl.h index 8d5ff4efdb..866fb7f4a2 100644 --- a/interface/wx/srchctrl.h +++ b/interface/wx/srchctrl.h @@ -139,6 +139,9 @@ public: Sets the search control's menu object. If there is already a menu associated with the search control it is deleted. + In the ports using the generic implementation of this control, e.g. + wxMSW, the menu can be opened from the keyboard using Alt-Down. + @param menu Menu to attach to the search control. */ diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 8956d91e2b..a4c6f87d04 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -81,6 +81,23 @@ protected: m_search->GetEventHandler()->ProcessEvent(event); } +#if wxUSE_MENUS + void OnKeyDown(wxKeyEvent& event) + { + // Alt-Down is the usual way of opening a drop-down menu and the only + // way of opening the search menu from the keyboard, as the button + // showing it doesn't accept focus. + if ( event.GetKeyCode() == WXK_DOWN && event.AltDown() && + m_search->HasMenu() ) + { + m_search->PopupSearchMenu(); + return; + } + + event.Skip(); + } +#endif // wxUSE_MENUS + void OnTextEnter(wxCommandEvent& WXUNUSED(event)) { if ( !IsEmpty() ) @@ -135,6 +152,9 @@ private: }; wxBEGIN_EVENT_TABLE(wxSearchTextCtrl, wxTextCtrl) +#if wxUSE_MENUS + EVT_KEY_DOWN(wxSearchTextCtrl::OnKeyDown) +#endif // wxUSE_MENUS EVT_TEXT(wxID_ANY, wxSearchTextCtrl::OnText) EVT_TEXT_ENTER(wxID_ANY, wxSearchTextCtrl::OnTextEnter) EVT_TEXT_MAXLEN(wxID_ANY, wxSearchTextCtrl::OnText)