This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Re: comment in managedwin.itb
- To: insight at sourceware dot cygnus dot com
- Subject: Re: comment in managedwin.itb
- From: Mo DeJong <mdejong at cygnus dot com>
- Date: Tue, 28 Nov 2000 12:54:53 -0800 (PST)
On 28 Nov 2000, Tom Tromey wrote:
> I see this code in managedwin.itb:
>
> # I don't understand this next line and no one commented it, so it's gone.
> #focus -force [focus -lastfor $top]
>
> focus $top
If you are looking for a better way to do that, you
could use this proc. It does the refocus management
with a -force except that it also handles the case
where the focus has not yet been assigned to a
widget in the given toplevel.
proc _refocus { window } {
set toplevel [winfo toplevel $window]
set last [focus -lastfor $window]
if {$toplevel == $last} {
focus -force $window
} else {
focus -force $last
}
}
Just call it like so:
_refocus $text
Of course, I am assuming that you want to actually snap
the focus to the given widget with -force here.
Mo DeJong
Red Hat Inc