#1878 tk numeric keypad bindings fail

obsolete: 8.4.9
closed-duplicate
5
2005-03-22
2005-03-22
No

platform: sparc solaris 8
most if not all Tk versions

Sun does weird key map assignments that result in users
having problems getting numeric keypad keys to work.
The following
code seems to work around the problem.

package provide KeypadBindings 1.0

# Replacement bindings for Sun keypad

namespace eval kpBnd {}

bind Entry <Left> [list kpBnd::fixBindingForKeypad %W
%A [bind Entry <Left>]]
bind Entry <KP_Left> \ [list kpBnd::fixBindingForKeypad %W %A [bind Entry
<Left>]]
bind Entry <Right> [list kpBnd::fixBindingForKeypad %W
%A [bind Entry <Right>]]
bind Entry <KP_Right> \ [list kpBnd::fixBindingForKeypad %W %A [bind Entry
<Right>]]
bind Entry <Delete> \ [list kpBnd::fixBindingForKeypad %W %A [bind Entry
<Delete>]]
bind Entry <KP_Insert> \ [list kpBnd::fixBindingForKeypad %W %A [bind Entry
<Insert>]]
bind Entry <F27> [list kpBnd::fixBindingForKeypad %W
%A [bind Entry <Home>]]
bind Entry <F33> [list kpBnd::fixBindingForKeypad %W
%A [bind Entry <End>]]
bind Entry <F29> [list kpBnd::fixBindingForKeypad %W
%A [bind Entry <Prior>]]
bind Entry <F35> [list kpBnd::fixBindingForKeypad %W
%A [bind Entry <Next>]]

bind Text <Up> [list kpBnd::fixBindingForKeypad %W
%A [bind Text <Up>]]
bind Text <KP_Up> \ [list kpBnd::fixBindingForKeypad %W %A [bind Text
<Up>]]
bind Text <Down> [list kpBnd::fixBindingForKeypad %W
%A [bind Text <Down>]]
bind Text <KP_Down> \ [list kpBnd::fixBindingForKeypad %W %A [bind Text
<Down>]]
bind Text <Left> [list kpBnd::fixBindingForKeypad %W
%A [bind Text <Left>]]
bind Text <KP_Left> \ [list kpBnd::fixBindingForKeypad %W %A [bind Text
<Left>]]
bind Text <Right> [list kpBnd::fixBindingForKeypad %W
%A [bind Text <Right>]]
bind Text <KP_Right> \ [list kpBnd::fixBindingForKeypad %W %A [bind Text
<Right>]]
bind Text <Delete> \ [list kpBnd::fixBindingForKeypad %W %A [bind Text
<Delete>]]
bind Text <KP_Insert> \ [list kpBnd::fixBindingForKeypad %W %A [bind Text
<Insert>]]
bind Text <F27> [list kpBnd::fixBindingForKeypad %W
%A [bind Text <Home>]]
bind Text <F33> [list kpBnd::fixBindingForKeypad %W
%A [bind Text <End>]]
bind Text <F29> [list kpBnd::fixBindingForKeypad %W
%A [bind Text <Prior>]]
bind Text <F35> [list kpBnd::fixBindingForKeypad %W
%A [bind Text <Next>]]

proc ::kpBnd::fixBindingForKeypad { win alpha
originalBinding } {

# remove non-printing characters like DEL (0177)
regsub -all {[^[:graph:]]} $alpha {} alpha
if { "$alpha" ne {} } {
$win insert insert $alpha
} else {
# replace %W with actual window in original binding
regsub -all "%W" $originalBinding "$win" binding
eval $binding
}
}

Perhaps these could go into the standard Tk distribution?

Discussion

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-03-22
    • status: open --> closed
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-03-22

    Logged In: YES
    user_id=72656

    This is a dup of some other report that purported to have a
    patch (which lvirden said didn't work). I'd rather see this
    follow-up there as a possible solution.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-03-22
    • status: closed --> closed-duplicate
     
  • Larry W. Virden

    Larry W. Virden - 2005-03-22

    Logged In: YES
    user_id=15949

    Jeff, I tried to find the other report, failed to locate it,
    and wanted to include the above code which we are using in
    production as a work around. If someone can find the other
    report to which you refer and wants to attach the above - or
    even will email me how to find
    the other report so I can attach it, please do so. I spent
    about an hour trying to find it.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks