wxGrid one-click-edit

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
freudi74
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Aug 30, 2019 9:03 am

wxGrid one-click-edit

Post by freudi74 » Fri Aug 30, 2019 9:25 am

Is there an easy way to make wxGrid "one-click-editable"?
At this time it needs two clicks (select, edit) to edit a value.

freudi74
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Aug 30, 2019 9:03 am

Re: wxGrid one-click-edit

Post by freudi74 » Fri Aug 30, 2019 11:25 am

I found an easy solution that seems to somewhat work, except that there's confusion when selecting multiple cells:

Code: Select all

wxGrid* _grid = new wxGrid(...);
...

_grid->Bind(wxEVT_GRID_CELL_LEFT_CLICK, [=](wxGridEvent & ev) {
	if (!_fiducials->IsReadOnly(ev.GetRow(), ev.GetCol())) {
		_grid->SetGridCursor(ev.GetRow(), ev.GetCol());
		_grid->EnableCellEditControl();
	}
	ev.Skip();
});

Post Reply