f



Re: catch key stroke before displaying in an entry #2

Thomas,

I just did this yesterday, but slightly differently.  In my case, I have
a series of data entry fields, which can be manually entered, or can be
loaded from a 2d barcode (1d or 2d is irrelevant, however).

The main trick is that most scanners can be set (or are by default?) to
invoke the Return key following a scan.

# Return key is invoked by barcode scanning.  Trap this key
# and see if a barcode was indeed scanned
$mw->bind('<Return>' => \&handle_enter);

Now, anyone can hit the return key, but it's easy enough to check to see
if the data meets our expectations of a valid barcode.  In my case, I
expect at least eleven vertical bars, with a '1' as the first symbol:

sub handle_enter {
    my ($widget) = @_;
    
    unless ($widget->isa('Tk::Entry')) {
        return;
    }
    
    my @f = split(/\|/, $widget->get);
    my $count = scalar(@f);
    
    unless ($count >= 11) {
        return; # not a barcode scan
    }
    
    # handle a version 1 barcode (currently the only version)
    if ($f[0] == 1) {
        $entries{some_field} = $f[1];
        $entries{some_other_field} = $f[2];
        $entries{some_yet_other_field} = $f[3];

        # Set the entry fields to read only
        set_entry_fields_state($entry_frame, 'readonly');
        $editable = 0;
        
        # Move the focus to the first active quantity field
        $entry_frame->Subwidget('MWC0009')->focus;
    }
    
    1;
}

The only subtle bit - the $entries{...} fields are also tied to the
Tk::Entry.  So, in the event that a barcode is scanned, the data that
was momentarily there is replaced by what was decoded during
handle_enter();
                                                                                
In the case of a 1d barcode, you could go look it up in your database to
validate it.  If you don't like the barcode, just set the $entry field
back to a blank value, display an error, or whatever.
  
On Mon, 2004-10-04 at 14:05, Thomas Kaiser wrote:
> Hello List
> 
> I have an application with a main window an several Entry's (input 
> boxes). I would like to check the pressed key before it is displaied in 
> the selected entry or even if no entry is selected (main window 
> selected). I need this to determine if the input is comming from the 
> keyboard or from a barcode scanner which is connected together with the 
> keyboard (and acts like a keyboard, I can add some post chars for the 
> barcode reader).
-- 
Regards,
Rich



-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
0
Rich
10/4/2004 8:46:53 PM
comp.lang.perl.tk 4721 articles. 0 followers. pharrendorf (19) is leader. Post Follow

0 Replies
206 Views

Similar Articles

[PageSpeed] 7

Reply:

Similar Artilces:

Re: catch key stroke before displaying in an entry
At 03:05 PM 10/4/2004, Thomas Kaiser wrote: >I have an application with a main window an several Entry's (input boxes). I would like to check the pressed key before it is displaied in the selected entry or even if no entry is selected (main window selected). I need this to determine if the input is comming from the keyboard or from a barcode scanner which is connected together with the keyboard (and acts like a keyboard, I can add some post chars for the barcode reader). > >I tried to "bind" the "KeyPress" event to the main window and hoped this will be t...

catch key stroke before displaying in an entry #2
This is a multi-part message in MIME format. --------------080703050600080808050205 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit --------------080703050600080808050205 Content-Type: message/rfc822; name="catch key stroke before displaying in an entry" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="catch key stroke before displaying in an entry" Message-ID: <41619F09.5040905@kaiser.linux-site.net> Date: Mon, 04 Oct 2004 21:05:45 +0200 From: Thomas Kaiser <thomas@kaiser.linux-s...

Re: catch key stroke before displaying in an entry #3
Thomas Kaiser <thomas@kaiser.linux-site.net> writes: >Hello List > >I have an application with a main window an several Entry's (input >boxes). I would like to check the pressed key before it is displaied in >the selected entry or even if no entry is selected (main window >selected). I need this to determine if the input is comming from the >keyboard or from a barcode scanner which is connected together with the >keyboard (and acts like a keyboard, I can add some post chars for the >barcode reader). > >I tried to "bind" the ...

RE: malfunctioning keys in sun 10-key under Perl/Tk #2
Troy.A Johnson wrote: > The problem we have is that using the 10 key > pad on our Sun model Type 5c keyboards almost > works. Everything is normal except: > > pressing '4' translates to 'left arrow' > pressing '6' translates to 'right arrow' We worked around this same issue from the application side (see discussion below). It would be nice to get a real fix in place. Dave Gordon Micron Technology, Inc. -----Original Message----- Sent: Wednesday, September 29, 2004 2:42 PM Subject: RE: Tk Entry Widget issue Accor...

catch key stroke before displaying in an entry
Hello List I have an application with a main window an several Entry's (input boxes). I would like to check the pressed key before it is displaied in the selected entry or even if no entry is selected (main window selected). I need this to determine if the input is comming from the keyboard or from a barcode scanner which is connected together with the keyboard (and acts like a keyboard, I can add some post chars for the barcode reader). I tried to "bind" the "KeyPress" event to the main window and hoped this will be the first callback which is cal...

catch key stroke before displaying in an entry #3
Hello Thanks for your tips. Here is my implementation of a barcode reader. # global variables my $BarCodeStart = 0; my $BarCodeEnd = 0; my $BarCode; my $EntryLength; $mw->bind("<KeyPress>", [ \&KeyPressed, Tk::Ev('K') ]); # Barcode format: degree <BARCODE> Return Control_L j sub KeyPressed { my $char = $_[1]; my ($widget) = @_; # End of Barcode if ($char eq "j" && $BarCodeStart == 1 && $BarCodeEnd == 1) { #Check if a Entry has the focus, if so, delete barcode if ($widget->isa('Tk::...

Re: Perl-tk cut and paste key bindings #2
Nick Ing-Simmons wrote: > The idea being to mimic key bindings that platform normaly provides. > Snag being that X11 isn't very regular in this regard. In particular > Control-C is no use in a terminal emulator window - as it kills the shell ;-) > What does Tcl/Tk do? > What do other X11 GUIs do (KDE/Gnome)? With the help of a few people with various different systems we have discovered that <Caps-Lock><Ctrl>c does the same as <Ctrl>c on every system and application where it does anything sensible. Also we have found that <Shift><C...

Re: Funny business with Perl/Tk 804.027-4, Entry and Optionmenuwidgets. #2
I made a hash of the version numbering. Apologies. Perl/Tk 804.027 caused me the probems and required the work-arounds mentioned. I installed it from a package. The package manager says: wk@asus:~$ dpkg --status perl-tk Package: perl-tk Status: install ok installed Priority: optional Section: perl Installed-Size: 9936 Maintainer: Michael C. Schultheiss <schultmc@debian.org> Architecture: i386 Version: 1:804.027-4 Replaces: libtk-png-perl Provides: libtk-perl, libtk-png-perl Depends: libc6 (>= 2.3.5-1), libjpeg62, libpng12-0 (>= 1.2.8rel), libx11-6, zlib1g (>...

Re: malfunctioning keys in sun 10-key under Perl/Tk
>The problem we have is that using the 10 key >pad on our Sun model Type 5c keyboards almost >works. Everything is normal except: > > pressing '4' translates to 'left arrow' > pressing '6' translates to 'right arrow' > > > is it true for any widget (e.g. Entry or Text) or you mean %K bind variable, and misbehaving only that? so "widget" demo also suffers this problem? In case this is true for all widgets, they try pure Tcl/Tk demo to check whether it also suffers same problem -++**==--++**==--++*...

Re: malfunctioning keys in sun 10-key under Perl/Tk #9
>>> konovalo <konovalo@mail.wplus.net> 03/15/05 12:34 AM >>> >>>>The problem we have is that using the 10 key >>>>pad on our Sun model Type 5c keyboards almost >>>>works. Everything is normal except: >>>>pressing '4' translates to 'left arrow' >>>>pressing '6' translates to 'right arrow' >>Also, running following code on Tcl/Tk interpreter: >>pack [text .t] >>will bring a Tcl/Tk GUI and widget on it for you to check behaviour >Using 'wish' ...

Re: malfunctioning keys in sun 10-key under Perl/Tk #10
"Troy.A Johnson" <troy.johnson@health.state.mn.us> wrote: > >>> konovalo <konovalo@mail.wplus.net> 03/15/05 12:34 AM >>> > >>>>The problem we have is that using the 10 key > >>>>pad on our Sun model Type 5c keyboards almost > >>>>works. Everything is normal except: > >>>>pressing '4' translates to 'left arrow' > >>>>pressing '6' translates to 'right arrow' > >>Also, running following code on Tcl/Tk interpreter: > >>pac...

Re: the better Perl/Tk book? (Re: Menu Creation) #2
At 06:47 PM 8/21/2003, Brian Wisti wrote: >Here's a related question: do the list folk consider "Mastering Perl/Tk" to be a good all-around tutorial/reference book, or is "Learning Perl/Tk" still the main tutorial choice? IMO, MP/Tk should be considered a second edition of LP/Tk. MP/Tk is the authoritative tutorial and reference book. Marc -++**==--++**==--++**==--++**==--++**==--++**==--++**== This message was posted through the Stanford campus mailing list server. If you wish to unsubscribe from this mailing list, send the message body of "unsu...

Re: malfunctioning keys in sun 10-key under Perl/Tk #7
>>> konovalo <konovalo@mail.wplus.net> 02/02/05 2:55 PM >>> >>>The problem we have is that using the 10 key >>>pad on our Sun model Type 5c keyboards almost >>>works. Everything is normal except: >>> pressing '4' translates to 'left arrow' >>> pressing '6' translates to 'right arrow' >Also, running following code on Tcl/Tk interpreter: >pack [text .t] >will bring a Tcl/Tk GUI and widget on it for you to check behaviour Using 'wish' to check out: pack [ text .t...

Re: malfunctioning keys in sun 10-key under Perl/Tk #8
>>>>The problem we have is that using the 10 key >>>>pad on our Sun model Type 5c keyboards almost >>>>works. Everything is normal except: >>>>pressing '4' translates to 'left arrow' >>>>pressing '6' translates to 'right arrow' >>>> >>>> >>Also, running following code on Tcl/Tk interpreter: >>pack [text .t] >>will bring a Tcl/Tk GUI and widget on it for you to check behaviour >> >> > >Using 'wish' to check o...

Web resources about - Re: catch key stroke before displaying in an entry #2 - comp.lang.perl.tk

List of mammals displaying homosexual behavior - Wikipedia, the free encyclopedia
For these mammals, there is documented evidence of homosexual behavior of one or more of the following kinds: sexual behavior , courtship , affection ...

Facebook Displaying Page Insights On Page Admins’ Personal Pages?
Some Facebook page administrators are seeing modules on their personal pages displaying page insights ad, campaign , and like totals for pages ...

Facebook Displaying Unread Messages from Pages in a New Updates Module
Facebook is displaying a new “Updates” sidebar module which shows some users unread messages sent to them by Pages. Users will see the Updates ...

Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air CNN Live - YouTube
Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air Lemon held up a Confederate flag first before holding up the sign. He asked, ...

Hazelwood coal mine fire: Morwell residents displaying symptoms similar to cigarette smokers, expert ...
An expert says some locals near Victoria's Hazelwood mine fire have symptoms similar to cigarette smokers.

Police accused of displaying fake G20 weapons
Toronto's top police officer misled the public by displaying fake weapons used in a medieval-themed role-playing game to help justify their actions ...

No charges for U.S. host for displaying high-capacity magazine on TV
NBC television journalist David Gregory won't face charges for displaying a high-capacity ammunition magazine on his "Meet the Press" news program ...

Jays' Escobar suspended three games for displaying slur
Toronto Blue Jays shortstop Yunel Escobar has been suspended three games for displaying a homophobic slur on his eye-black during a game on Saturday. ...

Google Play Store now displaying age-based ratings
We reported back in May that Google was adding age-based ratings to all apps in the Play Store as determined by the International Age Rating ...

Apple displaying Ferraris & other cars at WWDC hinting at CarPlay announcements
... 2014 Filed under: AAPL Company , iOS Continue reading more about AAPL Company and iOS at 9to5Mac . What do you think? Discuss "Apple displaying ...

Resources last updated: 2/6/2016 6:05:27 PM