Re: recursive grab current - raise - update



Bo Siltberg wrote:
I have found this piece of code in a large application.

#bind the mose button click events to raise the child window so
#that the parent SEA window does not freeze when the child window
#gets obscured

bind all <Motion> {
set current [grab current .]
set children [winfo children .]
foreach temp $current {
raise $current
update
}
}

Same binding for <Expose>.

which generates lots of "too many nested evaluations" when some subwindows
is moved around on screen. I am a novice in Tk but the update in this proc
looks bad to me. What does the proc's do really? Can I simply delete them?

Yes, the update is bad..., really bad thing to call update like this
inside an event handler.

The code is bad for other reasons too, as Bindings execute in global
scope so this code modifes the global variables current, children and
temp, which might be wanted or not.

Basically this code looks if there is any window having a grab then
tries to raise it to the top of the stacking order with raise.

The code looks strange with the unused $children and $temp variables,
either some strange side effect is invoked or its just bad code.

You could try to delete it, but it might have some useful purpose (the
raise call).

Michael







.