From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mo DeJong To: insight@sourceware.cygnus.com Subject: Re: comment in managedwin.itb Date: Tue, 28 Nov 2000 12:54:00 -0000 Message-id: References: <87pujf95nc.fsf@creche.cygnus.com> X-SW-Source: 2000-q4/msg00295.html 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