There are actually two concepts of "focus." In a multi-application environment, only one
application has focus at a time (when you type characters, those characters are sent to only one of the applications currently running). And in a given application, only one
widget has focus at a time (when you type characters, they appear in only one widget in the currently active application).
By default, the
force command assigns widget focus within an application. The application that has application focus is usually determined by the window manager.
What you'll need to do in this case is to use the
focus -force option, for example:
The
-force option not only gives focus to the widget you specify, but also gives focus to the application. Use this option sparingly, though. It's usually considered "rude" for an application to go around grabbing focus for itself; most of the time you're expected to let the window manager play "traffic cop" in deciding which applications gets focus when.
By the way, if you'd also like for all of the characters in the entry to be selected (for example, so that the user could just start typing to overwrite the old value with a new one) use the
selection range operation on your entry widget. You might also want to position the insertion cursor at the end of the text; use the
icursor operation to position the insertion cursor to a given character index. So, you might want to combine these operations as follows:
Code:
.e selection range 0 end
.e icursor end
- Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax