question about Grid Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
violethill
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Feb 03, 2009 8:39 am

question about Grid

Post by violethill » Mon Mar 09, 2009 9:13 am

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

lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Mon Mar 09, 2009 9:36 am

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 )
        {
           ....

violethill
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Feb 03, 2009 8:39 am

Post by violethill » Mon Mar 09, 2009 9:53 am

thanks lester !

Post Reply