Add a test of catching wxEVT_CONTEXT_MENU to the grid sample
Verify that these events are seen as coming from the grid itself after the changes of the previous commit.
This commit is contained in:
@@ -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) )
|
||||
{
|
||||
|
@@ -122,6 +122,8 @@ class GridFrame : public wxFrame
|
||||
|
||||
void OnGridCustomTab(wxGridEvent& event);
|
||||
|
||||
void OnGridContextMenu(wxContextMenuEvent& event);
|
||||
|
||||
public:
|
||||
GridFrame();
|
||||
~GridFrame();
|
||||
|
Reference in New Issue
Block a user