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
According to "perldoc Tk::bind",
<snip>
$widget->bind(tag,sequence,callback)
<snip>
If the tag is the name of a class of widgets, such as Tk::Button, the
binding applies to all widgets in that class;
<snip>
So I haven't tried it, but maybe this would work:
$MW->bind('Tk::Entry', '<KeyPress>' =>
sub {
<same XEvent stuff as below>
}
);
-----Original Message-----
Sent: Wednesday, September 29, 2004 2:33 PM
Subject: RE: Tk Entry Widget issue
So I would have to do that for each Entry instance.
How does it work for the entire entry class?
-----Original Message-----
Sent: Wednesday, September 29, 2004 2:30 PM
Subject: RE: Tk Entry Widget issue
We had this same issue on Sun keyboards with Perl 5.6.1 and Tk 800.023.
Not sure if this has been fixed in newer versions, but see the code
below for how we worked around it. If I remember correctly, reassigning
the tag precedence order with "bindtags" unfortunately messed up the
-validate functionality of the entry widget. Maybe the '<KeyPress>'
binding could have been bound to the entire Entry class instead of
individual Entry instances, and the "bindtags" would not have been
necessary.
-- Dave
#!/usr/local/bin/perl -w
use Tk;
use strict;
my $MW = MainWindow->new();
my $var;
my $e = $MW->Entry(
-width => 8,
-textvariable => \$var,
)->pack;
$e->focus;
fix_keypad($e); # Fix Sun keypad for this widget
$MW->Button(
-text => 'Exit',
-command => sub {
exit;
},
)->pack;
MainLoop;
#-----------------------------------------------------------------------
-----
# Subroutine: fix_keypad
#
# Override keypress bindings so that Sun keypads work properly.
#-----------------------------------------------------------------------
-----
sub fix_keypad {
my ($widget) = @_;
$widget->bind('<KeyPress>' =>
sub {
my $e = $_[0]->XEvent;
if ($e->A eq '4' and $e->K eq 'Left') {
$_[0]->eventGenerate('<KeyPress>', -keysym => '4' );
Tk->break;
}
elsif ($e->A eq '6' and $e->K eq 'Right') {
$_[0]->eventGenerate('<KeyPress>', -keysym => '6' );
Tk->break;
}
elsif ($e->A eq '.' and $e->K eq 'Delete') {
$_[0]->eventGenerate('<KeyPress>', -keysym => 'period' );
Tk->break;
}
}
);
$widget->bindtags([$widget,ref($widget),$widget->toplevel,'all']);
}
-----Original Message-----
Sent: Wednesday, September 29, 2004 1:34 PM
Subject: Tk Entry Widget issue
Folks,
The 4 & 6 keys on certain key boards fail to recognize the 4 & 6 keys on
the ten key pad as anything other than a cursor left and a cursor right
even it the NumLock is on.
This happens in Unix on Windows.
The problem is that I can't just intercept the Left or Right from the
ten key and place what I need because then I lose my cursor keys.
(Yes, my users will use these keys in a single line entry widget)
Any ideas?
There is a lot of folks asking about this on the internet but I found no
solutions.
Thanks,
Mike
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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@xxxxxxxxxxxxxxxxxx
|