Show events from wxSearchCtrl menu in the widgets sample
Verify that we get the expected events from the menu items.
This commit is contained in:
parent
9f1dc5ffff
commit
7112582f18
@ -53,7 +53,8 @@ enum
|
||||
ID_CANCEL_CB,
|
||||
ID_MENU_CB,
|
||||
|
||||
ID_SEARCHMENU
|
||||
ID_SEARCHMENU,
|
||||
ID_SEARCHMENU_LAST = ID_SEARCHMENU + 5
|
||||
};
|
||||
|
||||
|
||||
@ -82,6 +83,8 @@ protected:
|
||||
void OnText(wxCommandEvent& event);
|
||||
void OnTextEnter(wxCommandEvent& event);
|
||||
|
||||
void OnSearchMenu(wxCommandEvent& event);
|
||||
|
||||
void OnSearch(wxCommandEvent& event);
|
||||
void OnSearchCancel(wxCommandEvent& event);
|
||||
|
||||
@ -113,6 +116,9 @@ wxBEGIN_EVENT_TABLE(SearchCtrlWidgetsPage, WidgetsPage)
|
||||
EVT_TEXT(wxID_ANY, SearchCtrlWidgetsPage::OnText)
|
||||
EVT_TEXT_ENTER(wxID_ANY, SearchCtrlWidgetsPage::OnTextEnter)
|
||||
|
||||
EVT_MENU_RANGE(ID_SEARCHMENU, ID_SEARCHMENU_LAST,
|
||||
SearchCtrlWidgetsPage::OnSearchMenu)
|
||||
|
||||
EVT_SEARCH(wxID_ANY, SearchCtrlWidgetsPage::OnSearch)
|
||||
EVT_SEARCH_CANCEL(wxID_ANY, SearchCtrlWidgetsPage::OnSearchCancel)
|
||||
wxEND_EVENT_TABLE()
|
||||
@ -187,10 +193,9 @@ void SearchCtrlWidgetsPage::RecreateWidget()
|
||||
wxMenu* SearchCtrlWidgetsPage::CreateTestMenu()
|
||||
{
|
||||
wxMenu* menu = new wxMenu;
|
||||
const int SEARCH_MENU_SIZE = 5;
|
||||
wxMenuItem* menuItem = menu->Append(wxID_ANY, "Recent Searches", "", wxITEM_NORMAL);
|
||||
menuItem->Enable(false);
|
||||
for ( int i = 0; i < SEARCH_MENU_SIZE; i++ )
|
||||
for ( int i = 0; i < ID_SEARCHMENU_LAST - ID_SEARCHMENU; i++ )
|
||||
{
|
||||
wxString itemText = wxString::Format("item %i",i);
|
||||
wxString tipText = wxString::Format("tip %i",i);
|
||||
@ -235,6 +240,12 @@ void SearchCtrlWidgetsPage::OnTextEnter(wxCommandEvent& event)
|
||||
event.GetString());
|
||||
}
|
||||
|
||||
void SearchCtrlWidgetsPage::OnSearchMenu(wxCommandEvent& event)
|
||||
{
|
||||
int id = event.GetId() - ID_SEARCHMENU;
|
||||
wxLogMessage("Search menu: \"item %i\" selected (%s).", id);
|
||||
}
|
||||
|
||||
void SearchCtrlWidgetsPage::OnSearch(wxCommandEvent& event)
|
||||
{
|
||||
wxLogMessage("Search button: search for \"%s\".", event.GetString());
|
||||
|
Loading…
Reference in New Issue
Block a user