wxGrid, custom editor and non-US Keyboard

I thought this was fixed...

Using 2.3.3.1 on Win2000 I run the wxGrid Custom Cell
Editor Demo. (Last button).

First of all, how is this demo supposed to work? The
custom cell editor is set for a cell and a column.
When these cells are edited, the first entered
character will get last in the cell (since there is
no self._tc.SetInsertionPointEnd() in the StartingKey
method. Is this what the demo intends to show?

Anyway, my problem is that while all other keys are
treated correctly, the first key, the one that is placed
in the cell by the StartingKey method is treated as if
I was typing on a US keyboard. So if the text I enter
in a cell begins with a key that is different that that
on a US keyboard, I get the wrong character in the cell.

I.e. "key = evt.GetKeyCode(); ch = chr(key)" doesn't work.
It seems to bypass the keyboard setting.

But it works in all cells without a custom cell editor!

IIRC, all cells worked like the ones in the custom cell
editor demo in 2.3.2. How do I manage to get it right now
if I need a custom editor?

···

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

Actually, my problem is that I show values in the
cells with a "tail" that should't be edited, so when
I begin editing the cells, I remove that tail, and
when I'm done editing, I put it back. If I can achieve
that effect without using a custom cell editor, that
would also be ok.

(I wonder how interested in global issues Mr. Kapor is... :wink:

···

At 01:47 2002-11-20 +0100, I wrote:

IIRC, all cells worked like the ones with the custom cell
editor demo in 2.3.2. How do I manage to get it right now
if I need a custom editor?

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

Magnus Lycka wrote:

I thought this was fixed...

Using 2.3.3.1 on Win2000 I run the wxGrid Custom Cell
Editor Demo. (Last button).

First of all, how is this demo supposed to work? The
custom cell editor is set for a cell and a column.
When these cells are edited, the first entered
character will get last in the cell (since there is
no self._tc.SetInsertionPointEnd() in the StartingKey
method. Is this what the demo intends to show?

To be honest I don't remember what it was intended to show, other than being an example of creating a wxGridCellEditor.

Anyway, my problem is that while all other keys are
treated correctly, the first key, the one that is placed
in the cell by the StartingKey method is treated as if
I was typing on a US keyboard. So if the text I enter
in a cell begins with a key that is different that that
on a US keyboard, I get the wrong character in the cell.

I.e. "key = evt.GetKeyCode(); ch = chr(key)" doesn't work.
It seems to bypass the keyboard setting.

Right, the key event hasn't been translated into a character yet. In 2.3.3 wxTextCtrl has a new method called EmulateKeyPress which takes a wxKeyEvent. I think this will do the key-->char translation for you.

···

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

Magnus Lycka wrote:

···

At 01:47 2002-11-20 +0100, I wrote:

IIRC, all cells worked like the ones with the custom cell
editor demo in 2.3.2. How do I manage to get it right now
if I need a custom editor?

Actually, my problem is that I show values in the
cells with a "tail" that should't be edited, so when
I begin editing the cells, I remove that tail, and
when I'm done editing, I put it back. If I can achieve
that effect without using a custom cell editor, that
would also be ok.

Maybe the EVT_GRID_EDITOR_SHOWN and _HIDDEN events will help?

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

Thanks, that saved me for now, but it's really not
an ideal solution. Before I place my data into the
wxTextCtrl, I need to validate that it's correct
input that should be allowed to start editing, and
I need to do things such as uppercase it etc.
Obviously this won't work if the code thinks my
letter is a "[" until it sends it to the wxTextCtrl...

I suppose that I could have a hidden wxTextCtrl somewhere
that I clear, feed with EmulateKeyPress and then fetch
data from, but I would prefer if there was something
cleaner than a hack like that.

Don't you think the key event should have a method for this?

···

At 13:54 2002-11-21 -0800, Robin Dunn wrote:

Right, the key event hasn't been translated into a character yet. In 2.3.3 wxTextCtrl has a new method called EmulateKeyPress which takes a wxKeyEvent. I think this will do the key-->char translation for you.

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se