By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,450 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

wxPython: Transferring keyboard events from one frame to another

P: n/a
Hi All,
I'm in the process of implementing a virtual keypad: I have a wxFrame
which contains a photo the keypad of some device, and I'm using it to
enter special keywords into an editor window (wxStc). Each part of the
photo is associated with a certain keyword, which is sent to the
editor frame and displayed inside the editor. This is working fine.
However, if I want a proper virtual keyboard I should also be able to
transfer the regular keypresses (keyboard events) from my virtual
keypad frame to the editor frame, in order to save the user the
trouble of clicking on the editor window every time in order to set
the focus.

I tried using wxPostEvent to transfer the KEY_DOWN event from the
keypad frame to the appropriate control in the editor frame. The
problem is that the event which I am posting is only caught if I
override the KEY_DOWN event. It does not find its way to the default
event handler of this event.

I have read that there are some problems with wxPostEvent in this
context, but was wondering if someone has found a workaround for this
issue, as this would be the simplest solution for my problem. Other
ideas are also welcome...

BTW, I'm working on MSW.

Thanks,
Ziv
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
> I'm in the process of implementing a virtual keypad: I have a wxFrame
which contains a photo the keypad of some device, and I'm using it to
enter special keywords into an editor window (wxStc). Each part of the
photo is associated with a certain keyword, which is sent to the
editor frame and displayed inside the editor. This is working fine.
However, if I want a proper virtual keyboard I should also be able to
transfer the regular keypresses (keyboard events) from my virtual
keypad frame to the editor frame, in order to save the user the
trouble of clicking on the editor window every time in order to set
the focus.


Question:
Is your 'virtual keypad' /showing keypresses/, or is your 'virtual
keypad' used for text entry with a mouse?
Jul 18 '05 #2

P: n/a
Josiah Carlson <jc******@nospam.uci.edu> wrote in message news:<bv**********@news.service.uci.edu>...
I'm in the process of implementing a virtual keypad: I have a wxFrame
which contains a photo the keypad of some device, and I'm using it to
enter special keywords into an editor window (wxStc). Each part of the
photo is associated with a certain keyword, which is sent to the
editor frame and displayed inside the editor. This is working fine.
However, if I want a proper virtual keyboard I should also be able to
transfer the regular keypresses (keyboard events) from my virtual
keypad frame to the editor frame, in order to save the user the
trouble of clicking on the editor window every time in order to set
the focus.


Question:
Is your 'virtual keypad' /showing keypresses/, or is your 'virtual
keypad' used for text entry with a mouse?


Hi Josiah,
My virtual keypad is used for text entry with a mouse, but I also want
to transfer regular keyboard key presses from the keypad to the
'client' window.

Ziv
Jul 18 '05 #3

P: n/a
> Hi Josiah,
My virtual keypad is used for text entry with a mouse, but I also want
to transfer regular keyboard key presses from the keypad to the
'client' window.


If your virtual keypad is a subclass of wxDialog, you're going to have a
problem. wxDialogs eat keypresses if you are not careful, especially 'tab'.

You should instead try to use a plain wxFrame or wxMiniFrame (check the
wxPython demo for code). Then just ignore keyboard events in the keypad
window (using event.Skip()), they should be passed up the parent
heirarchy and get to your main application without much effort. If this
doesn't work for you, here's what I like to do:

#parent frame
def OnKeypress(self, event):
#handle the standard keypress events

#child frame
def OnKeypress(self, event):
self.parent.OnKeyPress(event)
Get that event to the keypress handler, no matter what the cost *wink*.
Another option would be to do the following:

#child frame
def OnKeypress(self, event):
a = event.Copy()
wxPostEvent(self.parent, a)
I hope this helps,
- Josiah
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.