WxGrid::SetGridCursor() problem

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Aug 09, 2010 12:39 pm

WxGrid::SetGridCursor() problem

Post by dgwsoft » Mon Aug 09, 2010 1:55 pm

I am running wxWidgets 2.8.10, gtk2-unicode-release-2.8, on a Centos Linux system.

What I want to achieve is that when the user finishes editing a cell in a WxGrid (by pressing ENTER) I control which cell is selected next, and put it in edit mode.

I can get this behaviour to kind-of work from a EVT_BUTTON event handler, with code like:

m_grid->SetGridCursor(i, j);

(kind-of, because I need to call both functions twice!) but this method fails when called from within the EVT_GRID_CELL_CHANGE event handler. My code is apparently ignored and the cursor goes to the cell below (where it goes by default).

The reason for this seems to be something to do with the grid creating its own EVT_GRID_SELECT_CELL event. When I put in a handler for this event (and print out its details) I can see both my event and the default event.

Strange thing is, the default event comes first, so I would expect my event to override it, but it doesn't.

I have tried calling Veto() on the default event, but this just produces strange behaviour (e.g. the grid does not update until the mouse cursor leaves the application).

Also I have tried calling wxSafeYield() before SetGridCursor(), and various combinations of ForceRefresh() and SetFocus(), but to no avail.

I think what I need is a way to turn off the default behaviour regarding cursor position, preferably without having to write my own editor.

Does anyone know of a way to do this? Thanks in advance.

Post Reply