diff --git a/samples/grid/griddemo.cpp b/samples/grid/griddemo.cpp index bc68dae5dc..df7810c7d6 100644 --- a/samples/grid/griddemo.cpp +++ b/samples/grid/griddemo.cpp @@ -614,6 +614,8 @@ GridFrame::GridFrame() grid->SetAttr(11, 11, new wxGridCellAttr); grid->SetAttr(11, 11, NULL); + grid->Bind(wxEVT_CONTEXT_MENU, &GridFrame::OnGridContextMenu, this, grid->GetId()); + wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); topSizer->Add( grid, 1, @@ -797,6 +799,23 @@ void GridFrame::SetTabCustomHandler(wxCommandEvent&) grid->Bind(wxEVT_GRID_TABBING, &GridFrame::OnGridCustomTab, this); } +void GridFrame::OnGridContextMenu(wxContextMenuEvent& event) +{ + // This is not supposed to happen: even if the grid consists of different + // subwindows internally, all context menu events should be seen as coming + // from the grid itself. + if ( event.GetEventObject() != grid ) + { + wxLogError("Context menu unexpectedly sent from non-grid window."); + } + else + { + wxLogMessage("wxEVT_CONTEXT_MENU in the grid at at (%d, %d)", + event.GetPosition().x, event.GetPosition().y); + } + + event.Skip(); +} void GridFrame::ToggleGridLines( wxCommandEvent& WXUNUSED(ev) ) { diff --git a/samples/grid/griddemo.h b/samples/grid/griddemo.h index 9c7ab3e8f3..a80c366b7b 100644 --- a/samples/grid/griddemo.h +++ b/samples/grid/griddemo.h @@ -122,6 +122,8 @@ class GridFrame : public wxFrame void OnGridCustomTab(wxGridEvent& event); + void OnGridContextMenu(wxContextMenuEvent& event); + public: GridFrame(); ~GridFrame();