Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing tab bind from widget 1

Status
Not open for further replies.

smugindividual

Programmer
Apr 14, 2003
104
US
I dont want my user to use Tab at all on a few screens.

Shouldnt the following line take care of removing the Tab bind for that widget?

bind $top <Key-Tab> {}

where top is the toplevel widget.
 
No, not quite. (That is, if I'm undertanding you correctly in that you're trying to suppress the default keyboard focus traversal mechanism with the Tab key on certain windows.)

First of all, if you're not already familiar with bindtags, I suggest you take a quick look at my replies in the threads Thread287-211083 and thread287-575956...

Okay, now that you're up to speed, you've probably figured out already what you need to do. The bindings for keyboard traversal appear in the [tt]all[/tt] bindtag. Because a widget's toplevel comes before the [tt]all[/tt] bindtag, we just need to suppress propagation of the [tt]<KeyPress-Tab>[/tt] events with a break command, like this:

Code:
bind $top <KeyPress-Tab> {break}

In most cases, because of the &quot;best event binding match&quot; algorithm used by Tk, this should also catch the reverse traversal binding as well. The reverse traversal binding is typically mapped to a [tt]<Shift-KeyPress-Tab>[/tt] event, but actually implemented with a virtual event named [tt]<<PrevWindow>>[/tt]. To be safest, though, I'd explicitly include a binding for it as well on the toplevel, to ensure that reverse traversal is suppressed as well:

Code:
bind $top <<PrevWindow>> {break}


- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top