Intercepting F2 key

I'm having a curious problem trying to get my controls to respond to the F2 key: it works fine for text boxes, but it never registers on combo boxes. The event just never fires, as far as I can tell. I'm not very good at figuring out where events are supposed to go, so perhaps someone could give me an idea of what is going wrong here and what I need to do.

Also, I found what appears to be an error in the documentation. I was trying to do FindFocus(), but wxWindow.FindFocus() doesn't work. I would never have figured it out if I hadn't found an example from the listserve: it's actually wxWindow_FindFocus(), which is an unusual format for wxPython. Anyway, I thought I ought to put this somewhere -- in the documentation, or on the wiki, or something -- but I don't know where it should go. If anyone can tell me, I will be glad to do it.

Sincerely,
Derek

It would be good to send it to wxPython-docs@lists.wxwindows.org
(I'm not sure about other places).
John

···

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Derek Croxton
Sent: 2004 01 08 12:48
To: wxpython-users@lists.wxwindows.org
Subject: [wxPython-users] Intercepting F2 key

I'm having a curious problem trying to get my controls to
respond to the
F2 key: it works fine for text boxes, but it never registers
on combo
boxes. The event just never fires, as far as I can tell.
I'm not very
good at figuring out where events are supposed to go, so
perhaps someone
could give me an idea of what is going wrong here and what I
need to do.

Also, I found what appears to be an error in the
documentation. I was
trying to do FindFocus(), but wxWindow.FindFocus() doesn't work. I
would never have figured it out if I hadn't found an example from the
listserve: it's actually wxWindow_FindFocus(), which is an unusual
format for wxPython. Anyway, I thought I ought to put this
somewhere --
in the documentation, or on the wiki, or something -- but I
don't know
where it should go. If anyone can tell me, I will be glad to do it.

Sincerely,
Derek

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwindows.org

Derek Croxton wrote:

I'm having a curious problem trying to get my controls to respond to the F2 key: it works fine for text boxes, but it never registers on combo boxes. The event just never fires, as far as I can tell. I'm not very good at figuring out where events are supposed to go, so perhaps someone could give me an idea of what is going wrong here and what I need to do.

How are you trying to catch it now? Where are you binding the event handlers and which events? What is your platform and version?

Also, I found what appears to be an error in the documentation. I was trying to do FindFocus(), but wxWindow.FindFocus() doesn't work. I would never have figured it out if I hadn't found an example from the listserve: it's actually wxWindow_FindFocus(), which is an unusual format for wxPython.

FindFocus is a static method in C++ and so classname_methodname is how SWIG represents it. In 2.5 that will be changing so that it uses a Python staticmethod(), so then it will be as you expected (and also the old way too.)

···

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

Robin Dunn wrote:

Derek Croxton wrote:

I'm having a curious problem trying to get my controls to respond to the F2 key: it works fine for text boxes, but it never registers on combo boxes. The event just never fires, as far as I can tell. I'm not very good at figuring out where events are supposed to go, so perhaps someone could give me an idea of what is going wrong here and what I need to do.

How are you trying to catch it now? Where are you binding the event handlers and which events? What is your platform and version?

WinXP, Python 2.3, wxPython 2.4.2.4
I've tried binding the event handlers in my subclass, but for the moment I'm doing it right on the form where the controls are instantiated. I hook on EVT_CHAR, which works fine in a wxTextCtrl, but not in a wxComboBox. Both of them catch other keys fine (e.g. escape). I've subclassed both of these controls, and they both respond to EVT_CHAR, but (a) they both include event.Skip() in the subclass; (b) they both work fine for other keys; and (c) even if I put event.Skip() as the first line of the subclass event handler, the combo box still doesn't catch F2. Very puzzling.

Also, I found what appears to be an error in the documentation. I was trying to do FindFocus(), but wxWindow.FindFocus() doesn't work. I would never have figured it out if I hadn't found an example from the listserve: it's actually wxWindow_FindFocus(), which is an unusual format for wxPython.

FindFocus is a static method in C++ and so classname_methodname is how SWIG represents it. In 2.5 that will be changing so that it uses a Python staticmethod(), so then it will be as you expected (and also the old way too.)

I understood this vaguely, but I thought that it should be classname.methodname. I also thought there were other static methods that didn't use this terminology, such as FindWindowByName...but I am far from understanding this all, and I trust Robin, so I will leave it at that. :slight_smile:

Sincerely,
Derek

Derek Croxton wrote:

Robin Dunn wrote:

Derek Croxton wrote:

I'm having a curious problem trying to get my controls to respond to the F2 key: it works fine for text boxes, but it never registers on combo boxes. The event just never fires, as far as I can tell. I'm not very good at figuring out where events are supposed to go, so perhaps someone could give me an idea of what is going wrong here and what I need to do.

How are you trying to catch it now? Where are you binding the event handlers and which events? What is your platform and version?

WinXP, Python 2.3, wxPython 2.4.2.4
I've tried binding the event handlers in my subclass, but for the moment I'm doing it right on the form where the controls are instantiated. I hook on EVT_CHAR, which works fine in a wxTextCtrl, but not in a wxComboBox. Both of them catch other keys fine (e.g. escape). I've subclassed both of these controls, and they both respond to EVT_CHAR, but (a) they both include event.Skip() in the subclass; (b) they both work fine for other keys; and (c) even if I put event.Skip() as the first line of the subclass event handler, the combo box still doesn't catch F2. Very puzzling.

Perhaps the native control is doing something with it that is preventing it from being turned into a wx event... Have you tried catching it via a wxAcceleratorTable?

···

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