This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: comment in managedwin.itb


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]