On Aug 3, 2009, at 1:39 AM, Alec Bennett wrote:
> I'm trying to bind a key event to a Python card window. Something
> like:
>
> self.Bind(wx.EVT_KEY_DOWN, self.onKey)
>
> The "onKey" function should be triggered whenever a key is pressed
> when the window has focus. The event isn't being caught though.
>
> Wondering if anyone might have any tips?
If you use the Message Watcher window (-m from the command-line) you
can see which events are firing when you type in your window. The
keyDown, keyUp, and keyPress events are your choices for processing.
Chances are you don't actually want a key event bound to the window
itself, since whatever component that has focus will actually be
getting the event and it will pass up the chain to the window. So,
chances are you'll have something like
on_keyPress(self, event):
keyCode = event.keyCode
if keyCode == 13:
print "user pressed return"
event.skip()
If you use the findfiles tool you can search for
on_.*_key
within the PythonCard folder and see all the samples and tools that
use keyDown, keyUp, and keyPress events.
ka
|