Page 1 of 1

question about Grid

Posted: Mon Mar 09, 2009 9:13 am
by violethill
Hi all,

I create MyGrid derived from wxGrid and I want to recieve right click on blank grid(not on label and cell)

so What should I do ?

Thanks for help

violethiLL

Posted: Mon Mar 09, 2009 9:36 am
by lester

Code: Select all

wxWindow* gridWindow = grid->GetGridWindow();
gridWindow->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( MyGrid::OnWhiteRightDown ) );

...

/**********************************************************************************************/
// User click on white space ( or cell - we must check it )
void MyGrid::OnWhiteRightDown( wxMouseEvent& event )
{
	wxWindow* window = (wxWindow*) event.GetEventObject();
	MyGrid* grid = (vsBaseGrid*) window->GetParent();

	int x = event.GetX();
	int y = event.GetY();

	// Get real coordinates for grid
	int sX, sY;
	( ( wxScrolledWindow* ) grid )->CalcUnscrolledPosition( x, y, &sX, &sY );

	int row = grid->YToRow( sY );
	int col = grid->XToCol( sX );

	// White space
	if( row == -1 )
        {
           ....

Posted: Mon Mar 09, 2009 9:53 am
by violethill
thanks lester !