Update wxSearchCtrl popup menu state after showing it

Fix the state of the check/radio items in the menu by updating the
template used by macOS to create the actual menu after showing it and
possibly changing the items state.

This is not ideal because changing the state from the program, e.g.
using wxMenuItem::Check(), still doesn't work correctly, i.e. isn't
reflected in the menu when it's shown, but better than nothing until a
better solution (which ideally would update the menu just before showing
it, but it's not clear how exactly can we do it, knowing that we don't
get wxEVT_MENU_OPEN for this menu neither) can be found.
This commit is contained in:
Vadim Zeitlin
2021-04-04 14:21:27 +02:00
parent 7112582f18
commit 0f1d1d2ae9
5 changed files with 26 additions and 2 deletions

View File

@@ -199,7 +199,7 @@ wxMenu* SearchCtrlWidgetsPage::CreateTestMenu()
{
wxString itemText = wxString::Format("item %i",i);
wxString tipText = wxString::Format("tip %i",i);
menu->Append(ID_SEARCHMENU+i, itemText, tipText, wxITEM_NORMAL);
menu->Append(ID_SEARCHMENU+i, itemText, tipText, wxITEM_CHECK);
}
return menu;
}
@@ -243,7 +243,8 @@ void SearchCtrlWidgetsPage::OnTextEnter(wxCommandEvent& event)
void SearchCtrlWidgetsPage::OnSearchMenu(wxCommandEvent& event)
{
int id = event.GetId() - ID_SEARCHMENU;
wxLogMessage("Search menu: \"item %i\" selected (%s).", id);
wxLogMessage("Search menu: \"item %i\" selected (%s).",
id, event.IsChecked() ? "checked" : "unchecked");
}
void SearchCtrlWidgetsPage::OnSearch(wxCommandEvent& event)