Problem with latest gtk2 and ComboPopup

Hi all

I was going to post the attached program as an example of a
wx.combo.ComboPopup in a thread about programatically opening a wx.ComboBox.
Then I found that it has stopped working on gtk2. I am now using 2.8.9.1 - I
think I was using 2.8.7.1 previously, and as far as I can remember it worked
ok then.

I am using a wx.ListBox as the underlying control. You can open the control
either by clicking the button or by pressing F4 or space. However, focus is
never passed to the ListBox, you cannot use the arrow keys to move up and
down, and it does not respond to my OnKey handler. It will only respond to a
mouse click.

It works correctly on MSW 2.8.9.1.

Any suggestions will be much appreciated.

Thanks

Frank Millman

fm55a.py (5.06 KB)

Frank Millman wrote:

Hi all

I was going to post the attached program as an example of a
wx.combo.ComboPopup in a thread about programatically opening a wx.ComboBox.
Then I found that it has stopped working on gtk2. I am now using 2.8.9.1 - I
think I was using 2.8.7.1 previously, and as far as I can remember it worked
ok then.

I am using a wx.ListBox as the underlying control. You can open the control
either by clicking the button or by pressing F4 or space. However, focus is
never passed to the ListBox, you cannot use the arrow keys to move up and
down, and it does not respond to my OnKey handler. It will only respond to a
mouse click.

IIRC focus is kept in the comboctrl so the user can still type into it while the popup is shown. If you want key events to have an effect on the contents of the popup then your comboctrl needs to manage it.

ยทยทยท

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

Robin Dunn wrote:

Frank Millman wrote:
> Hi all
>
> I am using a wx.ListBox as the underlying control. You can
open the control
> either by clicking the button or by pressing F4 or space.
However, focus is
> never passed to the ListBox, you cannot use the arrow keys
to move up and
> down, and it does not respond to my OnKey handler. It will
only respond to a
> mouse click.

IIRC focus is kept in the comboctrl so the user can still
type into it
while the popup is shown. If you want key events to have an
effect on
the contents of the popup then your comboctrl needs to manage it.

Thanks for the response, Robin. I tried a number of things, but none of them
worked.

Firstly, I am trying to emulate wx.Choice, so I do not want the user to type
into the control. I realise now that I am making the control un-editable by
fluke. I set up an OnComboKeyEvent handler, but I did not put evt.Skip() at
the end, so any keystrokes not handled are ignored. This happens to be what
I want, but I had not realised that this is what I had done.

I tried two other ways of making it un-editable. If I get a reference to the
underlying TextCtrl and call SetEditable(False), this seems to work ok. If I
set the wx.CB_READONLY style, it has an undesired side-effect. In my
OnComboKeyEvent handler, I want to trap the up/down arrows and use it to
scroll the contents of the popup in-situ, without actually opening the
popup. On msw, if I set wx.CB_READONLY, it traps the up/down arrows before I
can get to them, and uses them to automatically open the popup! It must be a
Windows thing.

Secondly, if I try ComboCtrl in the demo, I can type into the control
provided the popup is *not* shown, but if it is shown, I cannot type into
the control, nor can I descend into the popup using the keyboard. I can make
a selection using the mouse, but then it immediately dismisses the popup and
returns. This seems to be a violation of the principle that you should be
able to navigate an entire screen using only the keyboard. On msw, I can
open the popup with F4, but I can only close it with the mouse. With gtk2, I
can only open and close the popup with the mouse.

I have tried to work around these limitations by setting up KeyEvent
handlers on both the ComboCtrl and the underlying ListBox. On msw, this
works ok, and I can get it to behave exactly as I want. On gtk2, it used to
work with 2.8.7.1 (as far as I can remember), but now, once the ListBox
popup is open, I cannot get it to respond to any keystrokes at all, in
either handler.

Any suggestions?

Thanks

Frank