logo       

RE: malfunctioning keys in sun 10-key under Perl/Tk: msg#00002

Subject: RE: malfunctioning keys in sun 10-key under Perl/Tk
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



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe