Bermingham Charles E wrote:
> 
> Do the different Tk widgets have different keyboard behaviors?  In other
> words, do the tk widget developers have a lot of control regarding the
> keyboard's behavior, or is there some standard interface? 

Look at the man page or doc for any widget, such as the listbox, and
there's a section called "Default Bindings" that gives the keyboard
behaviour.

You can override the defaults with the "bind" command (see doc).

> It seems to
> me that Tk itself may have some weird keyboard behavior.  For instance,
> tabbing through the buttons on a window will get you to the button you
> want, but you must press <space> to press the button.  In Windows,
> <Enter> accomplishes the same thing.  Could someone give me a clue how I
> would fix this?  It would really help me get going on this.

If you look at the file "button.tcl" in the "library" directory of the
tk code, you'll find the default bindings for the button class:

bind Button <space> {
    tkButtonInvoke %W
}

So, you can add the Return key to _all_ buttons with this in your code:

bind Button <Return> {
    tkButtonInvoke %W
}

Or, for just one particular button:

bind .b <Return> {
    tkButtonInvoke %W
}

Here is a little test program:

button .b -command {puts "OK"}
pack   .b
focus  .b
bind Button <Return> {
    tkButtonInvoke %W
}

The focus is there to make the button receive the keystrokes. Or, you
can press the TAB key to do the same thing.

-- 
...RickM...

Reply via email to