wx.TextEntry AutoComplete() eats EVT_TEXT_ENTER ?

32 views
Skip to first unread message

C M

unread,
Nov 9, 2015, 1:59:02 PM11/9/15
to wxPytho...@googlegroups.com
I am trying to implement basic autocomplete for a comboCtrl. The text entry field for a ComboCtrl is made from a wx.TextEntry base class, which I see has an AutoComplete() method as of about wx2.9. Good.

But, it seems that using this AutoComplete() method somehow causes the wx.EVT_TEXT_ENTER event that I bind to the ComboCtrl to be ignored. Binding that event to the ComboCtrl's wx.TextEntry itself doesn't work, either. This is not good, because I want the user to be able to use the Enter key to "finalize" the selection and act on it (which is a common need in most GUIs, such as in a Firefox's "awesome bar" and all URL bars in browsers, where hitting Enter causes you to go to that page).

See the attached runnable sample for a demonstration of this issue. Any ideas on how to work around this?

Thanks,
Che
testing_comboCtrl_autocomplete.py

C M

unread,
Nov 11, 2015, 1:38:49 PM11/11/15
to wxPytho...@googlegroups.com

But, it seems that using this AutoComplete() method somehow causes the wx.EVT_TEXT_ENTER event that I bind to the ComboCtrl to be ignored.

Ut! As always, should have searched the web more thoroughly for this, since Robin has already answered this question--almost three years ago:

https://groups.google.com/d/msg/wxpython-users/tgQcNj0b1kY/f4aSZGmNUO0J

I followed his point #1 and bound EVT_KEY_DOWN; Enter will generate a key code of 13, which can be gotten from within the event handler with keycode = event.GetKeyCode() (or you can use GetUnicodeKey() ) and then checking if it is 13 and if so doing what I need to and if not calling event.Skip(). Works well now. Thanks, Robin.

Che

Reply all
Reply to author
Forward
0 new messages