Question

I have a wxListCtrl and I would like to make it so that when a user right click on an item to show up a contextmenu/popup.

How can I do this with wxFormBuilder or programatically?

Cheers.

No correct solution

OTHER TIPS

You need to catch the event of type wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK or wxEVT_CONTEXT_MENU (more general, thanks vadz) and then pop up a wxMenu.

An example of this can be seen in the wxListCtrl sample, which can be found in wxdir\samples\listctrl. A short snippet modified from the sample should give you the right idea:

void MyListCtrl::OnRightClick(wxListEvent& event)
{
    // Show popupmenu at position
    wxMenu menu(wxT("Test"));
    menu.Append(LIST_ABOUT, wxT("&About"));
    PopupMenu(&menu, event.GetPoint());
}

Take a look at the example in http://wiki.wxwidgets.org/WxMenu

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top