[wxPython] Grid cell text editing question: capturing KEY_DOWN on a cell

Hi all

I am trying to enable user to be able to move up and down while being in the
'edit' mode of a grid cell.
Cells seem to catch enter key event, but I cannot make it capture up, down
(or actually any other key besides the first key pressed and enter key)
arrows.

I tried to create a class derived from wxGridCellTextEditor, but I cannot
make the class capture KEY_DOWN event either..

What is actually in charge of accepting key strokes when I am in an 'edit'
mode on a grid cell?

Any help will be appreciated.

TIA

Hanna

I'm not sure if it works when you inherit from wxGridCellTextEditor, but
the event sure works if you inherit from wxPyGridCellEditor. You can see
an example of it in the file GridCustEditor.py. which is one of the demo
files.
To set the Key_Down event for that particular demo file, just add the
line
EVT_KEY_DOWN(self._tc, self.EvtKeyDown)
right after the line
self._tc.SetInsertionPoint(0)
of the Create event

To test it you can just add this function
def EvtKeyDown(self, event):
   k = event.GetKeyCode()
   print k
   event.Skip()

Hope it helps

Just courisity.... What do you want to do with the KEY_DOWN event in you
application???

Raul

Hanna Joo wrote:

···

Hi all

I am trying to enable user to be able to move up and down while being in the
'edit' mode of a grid cell.
Cells seem to catch enter key event, but I cannot make it capture up, down
(or actually any other key besides the first key pressed and enter key)
arrows.

I tried to create a class derived from wxGridCellTextEditor, but I cannot
make the class capture KEY_DOWN event either..

What is actually in charge of accepting key strokes when I am in an 'edit'
mode on a grid cell?

Any help will be appreciated.

TIA

Hanna

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

I tried to create a class derived from wxGridCellTextEditor, but I cannot
make the class capture KEY_DOWN event either..

What is actually in charge of accepting key strokes when I am in an 'edit'
mode on a grid cell?

The cell editors are simply wrappers around some wxControl that allow it to
plug into the grid. It is the control inside the editor class that is the
actual window that gets events. As Raul has already answered, if you derive
your own editor from wxPyGridCellEditor as shown in the demo then you have
complete control of what events are captured and what behaviours are
implemented.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!