windows oddities: ComboBox gets no EVT_CHAR for arrows/delete - alt arrow not working as accelerator

hi,

windows oddity 1: arrow key in combobox doesn't generate EVT_CHAR

i've just noticed that some code i wrote a few months ago no
longer works on windows (xp). it's a ComboBox with handlers for
EVT_CHAR and EVT_TEXT but it doesn't seem to be receiving any
EVT_CHAR events for up/down arrow keys any more, only EVT_TEXT
(and EVT_KEY_DOWN).

is it my imagination that this used to work or has something
changed that could explain this? i've upgraded wxpython from
2.8.8.x or 2.8.9.x to 2.8.10.1 since writing it but i doubt that
that has anything to do with it.

i've "fixed" it by handling EVT_KEY_DOWN and calling the EVT_CHAR
handler under the necessary circumstances but i'd also like to
understand what happened (if anything). does anyone know?

windows oddity 2: alt arrow keys don't work as accelerators

i've also noticed that alt arrow keys no longer work in windows
as accelerators. i'm almost sure that they used to work too. now
it's producing EVT_KEY_DOWN and EVT_CHAR events instead of
executing the associated menu item handler.

i've "fixed" this by changing the accelerators to
Ctrl-Alt-Up/Left/Right because it was quicker and easier than
putting in a hack to detect these keys in every control's
EVT_KEY_DOWN handler and calling the associated menu item
handler manually but i'd like to understand this as well.
is it a bug or a windows feature?

windows oddity 3: delete in combobox doesn't generate EVT_CHAR

and now i've just noticed that on windows, ComboBox doesn't
receive EVT_CHAR for the Delete key as it does in macosx (and as
it would for a backspace key in windows). this may have always
been the case. i don't know. but it means i need yet another hack
to detect this and handle it correctly.

windows oddity 4: ComboBox.SetItems clears text as well

this may have always been the case as well. i don't know.
but it's something to be wary of.

cheers,
raf

Hi Raf,

hi,

windows oddity 1: arrow key in combobox doesn't generate EVT_CHAR

i've just noticed that some code i wrote a few months ago no
longer works on windows (xp). it's a ComboBox with handlers for
EVT_CHAR and EVT_TEXT but it doesn't seem to be receiving any
EVT_CHAR events for up/down arrow keys any more, only EVT_TEXT
(and EVT_KEY_DOWN).

is it my imagination that this used to work or has something
changed that could explain this? i've upgraded wxpython from
2.8.8.x or 2.8.9.x to 2.8.10.1 since writing it but i doubt that
that has anything to do with it.

i've "fixed" it by handling EVT_KEY_DOWN and calling the EVT_CHAR
handler under the necessary circumstances but i'd also like to
understand what happened (if anything). does anyone know?

windows oddity 2: alt arrow keys don't work as accelerators

i've also noticed that alt arrow keys no longer work in windows
as accelerators. i'm almost sure that they used to work too. now
it's producing EVT_KEY_DOWN and EVT_CHAR events instead of
executing the associated menu item handler.

i've "fixed" this by changing the accelerators to
Ctrl-Alt-Up/Left/Right because it was quicker and easier than
putting in a hack to detect these keys in every control's
EVT_KEY_DOWN handler and calling the associated menu item
handler manually but i'd like to understand this as well.
is it a bug or a windows feature?

windows oddity 3: delete in combobox doesn't generate EVT_CHAR

and now i've just noticed that on windows, ComboBox doesn't
receive EVT_CHAR for the Delete key as it does in macosx (and as
it would for a backspace key in windows). this may have always
been the case. i don't know. but it means i need yet another hack
to detect this and handle it correctly.

windows oddity 4: ComboBox.SetItems clears text as well

this may have always been the case as well. i don't know.
but it's something to be wary of.

cheers,
raf

Do you have the style wx.WANTS_CHARS enabled on your combobox? I think
that will fix most of your EVT_CHAR issues.

The SetItems thing is defined as

self.Clear()
self.AppendItems(items)

So that's no surprise. See "_core.py".

- Mike

···

On Jun 30, 8:53 pm, raf <r...@raf.org> wrote:

raf wrote:

hi,

windows oddity 1: arrow key in combobox doesn't generate EVT_CHAR

As Mike said, using wx.WANTS_CHARS style should fix this.

windows oddity 2: alt arrow keys don't work as accelerators

Please open a wxTrac ticket about this and include a small sample app that shows the problem.

windows oddity 3: delete in combobox doesn't generate EVT_CHAR

I'm not sure about this one...

windows oddity 4: ComboBox.SetItems clears text as well

See Mike's answer.

···

--
Robin Dunn
Software Craftsman

raf wrote:

windows oddity 1: arrow key in combobox doesn't generate EVT_CHAR
windows oddity 2: alt arrow keys don't work as accelerators
windows oddity 3: delete in combobox doesn't generate EVT_CHAR
windows oddity 4: ComboBox.SetItems clears text as well

Mike Driscoll wrote (Jul 1 11.58pm):

Do you have the style wx.WANTS_CHARS enabled on your combobox? I think
that will fix most of your EVT_CHAR issues.

yes, i do. sorry i didn't mention that.

The SetItems thing is defined as
self.Clear()
self.AppendItems(items)
So that's no surprise. See "_core.py".
- Mike

ok, then. the fact that it doesn't clear the text when it
clears the items on macosx is the oddity :slight_smile:

Robin Dunn wrote (Jul 2 10.20am):

windows oddity 1: arrow key in combobox doesn't generate EVT_CHAR

As Mike said, using wx.WANTS_CHARS style should fix this.

but doesn't.

windows oddity 2: alt arrow keys don't work as accelerators

Please open a wxTrac ticket about this and include a small
sample app that shows the problem.

ok.

windows oddity 3: delete in combobox doesn't generate EVT_CHAR

I'm not sure about this one...

windows oddity 4: ComboBox.SetItems clears text as well

See Mike's answer.

but it doesn't clear the text on macosx. maybe that's a bug?

cheers,
raf

raf wrote:

windows oddity 4: ComboBox.SetItems clears text as well

See Mike's answer.

but it doesn't clear the text on macosx. maybe that's a bug?

Yes, I think so.

···

--
Robin Dunn
Software Craftsman