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?
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/CAA9_n-VLG5cQVMes0Hm=o8-noZn04=WA7A4yeMKWYWhQ8iyr+A@mail.gmail.com
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: Dabo-users@leafe.com
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/4F29864D.5040005@ulmcnett.com
Author: Jacek Kałucki
Posted: 2012-02-04 11:48:38 Link
Użytkownik Paul McNett napisał:
> Unfortunately I don't think there is a clean way of doing this (wxPython limitation).
Hi.
Actually, there is a way to capture and handle events globally.
The way to achieve this is to use dApp.UIAppClass property.
Then you have to create your own class inherited from uiApp class and
define the FilterEvent method in it.
I'm using this method to handle barcode reader output in my applications.
--
Regards
Jacek Kałucki
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/4F2D6166.3050201@rz.onet.pl
Author: John Fabiani
Posted: 2012-02-04 13:27:17 Link
On Saturday, February 04, 2012 05:48:38 PM Jacek Kałucki wrote:
> I'm using this method to handle barcode reader output in my applications.
That sounds interesting - if you don't mind tells more about what you are
doing.
Johnf
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/6446643.aQISO59XX6@linux-12
Author: Jacek Kałucki
Posted: 2012-02-05 14:23:17 Link
Użytkownik John Fabiani napisał:
> That sounds interesting - if you don't mind tells more about what you are
> doing.
Here is link to sample code that handles barcode reader output: http://dabo.codepad.org/zx8I2NXN
--
Regards
Jacek Kałucki
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/4F2ED725.9020107@rz.onet.pl
Author: Jacek Kałucki
Posted: 2012-02-05 14:33:38 Link
Użytkownik Jacek Kałucki napisał:
> Here is link to sample code that handles barcode reader output:http://dabo.codepad.org/zx8I2NXN
Sorry, correct link here: http://dabo.codepad.org/XcamafIR
I missed dApp.UIAppClass property setting first time.
--
Regards
Jacek Kałucki
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/4F2ED992.6040505@rz.onet.pl
Author: John Fabiani
Posted: 2012-02-06 09:19:20 Link
On Sunday, February 05, 2012 08:33:38 PM Jacek Kałucki wrote:
> Użytkownik Jacek Kałucki napisał:
> > Here is link to sample code that handles barcode reader
> > output:http://dabo.codepad.org/zx8I2NXN
> Sorry, correct link here: http://dabo.codepad.org/XcamafIR
> I missed dApp.UIAppClass property setting first time.
Interesting code. What platform required the code? While working with
barcode readers in the past (I have only used symbol) they just acted as a
keyboard. I did not find it necessary to write any code. I did however have
to strip out the beggining and ending char's to gain access to the data. But
I was doing that anyway. Your code avoids the stripping.
Johnf
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/2504111.rxL1ftjuPt@linux-12
Author: Jacek Kałucki
Posted: 2012-02-06 10:19:42 Link
Użytkownik John Fabiani napisał:
> Interesting code. What platform required the code? While working with
> barcode readers in the past (I have only used symbol) they just acted as a
> keyboard. I did not find it necessary to write any code. I did however have
> to strip out the beggining and ending char's to gain access to the data. But
> I was doing that anyway. Your code avoids the stripping.
I have Windows platform application with DataLogic scanners supported.
But I think it should work in any software environment and with any scanner
with Wedge interface support, the only thing to do is to customize scanned code prefix and suffix.
The main advantage of this code is that you have no longer need to put focus on control
that accept keyboard output.
You can trigger scan button anywhere the focus is placed.
--
Regards
Jacek Kałucki
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/4F2FEF8E.9010504@rz.onet.pl
Author: John Fabiani
Posted: 2012-02-06 10:50:46 Link
On Monday, February 06, 2012 04:19:42 PM Jacek Kałucki wrote:
> Użytkownik John Fabiani napisał:
> > Interesting code. What platform required the code? While working with
> > barcode readers in the past (I have only used symbol) they just acted as
> > a keyboard. I did not find it necessary to write any code. I did
> > however have to strip out the beggining and ending char's to gain
> > access to the data. But I was doing that anyway. Your code avoids the
> > stripping.
>
> I have Windows platform application with DataLogic scanners supported.
> But I think it should work in any software environment and with any scanner
> with Wedge interface support, the only thing to do is to customize scanned
> code prefix and suffix. The main advantage of this code is that you have no
> longer need to put focus on control that accept keyboard output.
> You can trigger scan button anywhere the focus is placed.
Thanks Jacek, looks like it's a good way to get the job done.
Johnf
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/2648657.W4VWBXxFyC@linux-12
On 2/6/12 7:50 AM, John Fabiani wrote:
> On Monday, February 06, 2012 04:19:42 PM Jacek Kałucki wrote:
>> Użytkownik John Fabiani napisał:
>>> Interesting code. What platform required the code? While working with
>>> barcode readers in the past (I have only used symbol) they just acted as
>>> a keyboard. I did not find it necessary to write any code. I did
>>> however have to strip out the beggining and ending char's to gain
>>> access to the data. But I was doing that anyway. Your code avoids the
>>> stripping.
>>
>> I have Windows platform application with DataLogic scanners supported.
>> But I think it should work in any software environment and with any scanner
>> with Wedge interface support, the only thing to do is to customize scanned
>> code prefix and suffix. The main advantage of this code is that you have no
>> longer need to put focus on control that accept keyboard output.
>> You can trigger scan button anywhere the focus is placed.
>
> Thanks Jacek, looks like it's a good way to get the job done.
I didn't realize there was a way to filter the events. Do I understand correctly that
FilterEvent gets the first opportunity to deal with events being raised? Is this
relatively new because I was looking for it back in wxPython 2.4 or 2.6 - I think
we'll wrap some of this to offer VFP's KeyPreview-like functionality (a bool
specifying whether the form or the control with focus gets the first opportunity to
deal with keypresses)...
Paul
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/4F300231.6010800@ulmcnett.com