On 2/1/12 6:10 AM, Asaf Greenberg wrote:
> I'm looking for documentation on how catch keyboard events everywhere in
> the application / or anywhere in a form.
> in particular = how to capture ESC and ENTER regardless on the control in
> focus?

Unfortunately I don't think there is a clean way of doing this (wxPython 
limitation). 
At least, I tried years ago to find one and failed. The Key events are 
"command" 
events, which means that they'll propagate up the containership hierarchy until 
an 
event handler handles it. However, there are controls that catch and handle the 
various key events in their own ways and not all of them resume propagation for 
other 
controls to handle.

Here's what should happen if the user presses Esc in a textbox on a panel on a 
form:

KeyDown and KeyUp events are raised at the appropriate time from the textbox, 
saying 
that Esc was pressed. If the textbox handles it, then it stops there. Otherwise 
it 
propagates up to the panel, then to the Form, and finally to the Application.

I've found that some controls may "eat" the keydown but propagate the keyup, so 
you'll need to do some experimenting. I just put the following code in one of 
my forms:

{{{
def initProperties(self):
   ...
   self.bindEvent(dabo.dEvents.KeyDown, self._onKeyDown)
   self.bindEvent(dabo.dEvents.KeyUp, self._onKeyUp)

def _onKeyDown(self, evt):
   print "KeyDown", evt.EventData

def _onKeyUp(self, evt):
   print "KeyUp", evt.EventData
}}}

I found that no matter what control I was on, when I pressed and released any 
key the 
"KeyUp" message would print. However, I never saw a "KeyDown" message. I tested 
on Linux.

I don't think Dabo is eating the KeyDown, but that should be the next test.

I put that same code in my dApp subclass, and found that I did receive KeyDown 
events 
however I received the KeyUp multiple times.

We need to look into these inconsistencies, but in the meantime I hope the 
information helps you.

Paul

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to