Reputation: 65
I'm trying to add a context menu to a grid control in wxWidgets 2.9.4 on Windows 10, and while I can get the context menu key to work right clicking doesn't. Right now I have the following in the header
void handle_contextMenu(wxContextMenuEvent& event);
void handle_rightButton(wxMouseEvent& event);
and in the constructor
Bind(wxEVT_CONTEXT_MENU, &DataGrid::handle_contextMenu, this);
Bind(wxEVT_RIGHT_UP, &DataGrid::handle_rightButton, this);
neither work for the right mouse button.
Upvotes: 0
Views: 397
Reputation: 22688
The reason you can't bind to these events on wxGrid
itself is that it's a composite window as explained in the "Accessors for component windows" section of the documentation. So to make this code work you need to call GetGridWindow()->Bind(...)
, for example.
Alternatively, you could, and probably should, if they're enough, use the higher level events such as the already mentioned wxEVT_GRID_CELL_RIGHT_CLICK
.
Upvotes: 1