Prev: ICNAAM 2010 Mini-Symposium on Computational Bioimaging and Visualization
Next: Tell if command was invoked from menu or button?
From: Helmut Giese on 10 Mar 2010 09:13 Hello out there, I need to detect when resizing my toplevel is about to start (and when its over as well). I can detect <Configure>, but that's a bit late (size already changed a bit) and - much worse - it doesn't tell me when resizing ended. I tried - detecting button clicks, but the one starting the resize operation goes unnoticed, - looking at the cursor since it changes prior to the actual resizing, but the toplevel never has a cursor. I am out of ideas. Any advice will be greatly appreciated. Best regards Helmut Giese
From: Uwe Klein on 10 Mar 2010 09:56 Helmut Giese wrote: > Hello out there, > I need to detect when resizing my toplevel is about to start (and when > its over as well). I can detect <Configure>, but that's a bit late > (size already changed a bit) and - much worse - it doesn't tell me > when resizing ended. > I tried > - detecting button clicks, but the one starting the resize operation > goes unnoticed, > - looking at the cursor since it changes prior to the actual resizing, > but the toplevel never has a cursor. > > I am out of ideas. Any advice will be greatly appreciated. > Best regards > Helmut Giese played around with <Configure> a couple of days ago. This is similar: #!/usr/bin/wish canvas .c pack .c -expand 1 -fill both ..c create oval -90 -90 110 110 -fill black -tags fleck label .lbw -textvariable ::configure(.c,width) ..c create window 50 10 -window .lbw label .lbh -textvariable ::configure(.c,height) ..c create window 10 50 -window .lbh label .lbx -textvariable ::configure(.c,status) ..c create window 50 50 -window .lbx -anchor w set ::configure(.c,cnt) 0 bind .c <Configure> { puts stderr "lastwidth:$::configure(.c,width) lastheight:$::configure(.c,height)" set ::configure(.c,status) moving set ::configure(.c,width) %w set ::configure(.c,height) %h incr ::configure(.c,cnt) after 500 configure_end $::configure(.c,cnt) set newcoords [ list \ [ expr ($::configure(.c,width) * 0.5 ) -10 ] \ [ expr ($::configure(.c,height) * 0.5 ) -10 ] \ [ expr ($::configure(.c,width) * 0.5 ) +10 ] \ [ expr ($::configure(.c,height) * 0.5 ) +10 ] \ ] .c coords fleck $newcoords .c itemconfigure fleck -fill red } proc configure_end {cnt args} { if {$cnt == $::configure(.c,cnt)} { .c itemconfigure fleck -fill black set ::configure(.c,status) stationary } } #end uwe
From: Helmut Giese on 10 Mar 2010 10:26 Hi Uwe, >played around with <Configure> a couple of days ago. >This is similar: yes, it is. [snip] So the idea is: resize is over when the user (resp. the mouse) hasn't moved for N msec (N = 500 in your example). Yes, it works and many thanks for sharing it. I still wonder, though: With all of Tcl's phantastic introspection facilities is there no way to detect the button press and release events which control the resize operation? Thanks again and best regards. Helmut Giese
From: Uwe Klein on 10 Mar 2010 10:48 Helmut Giese wrote: > Hi Uwe, > >>played around with <Configure> a couple of days ago. >>This is similar: > > yes, it is. > [snip] > So the idea is: resize is over when the user (resp. the mouse) hasn't > moved for N msec (N = 500 in your example). independent of the mouse. > Yes, it works and many thanks for sharing it. > > I still wonder, though: With all of Tcl's phantastic introspection > facilities is there no way to detect the button press and release > events which control the resize operation? > Thanks again and best regards. > Helmut Giese you would have to hook into the window manager? uwe
From: Bruce Hartweg on 10 Mar 2010 11:09
Helmut Giese wrote: > Hi Uwe, >> played around with <Configure> a couple of days ago. >> This is similar: > yes, it is. > [snip] > So the idea is: resize is over when the user (resp. the mouse) hasn't > moved for N msec (N = 500 in your example). > Yes, it works and many thanks for sharing it. > > I still wonder, though: With all of Tcl's phantastic introspection > facilities is there no way to detect the button press and release > events which control the resize operation? > Thanks again and best regards. > Helmut Giese The issue is this is resizing of the top level window which is handled by the window manager, NOT Tcl. In fact some window managers you can configure how resize works - either constantl;y growing the window or by dragging and outline of the new size and the window only resizes after the user lets go. My news reader missed the post that you snipped, but I assume it was just a configure handler the set flags/timers to handle the case you need. bruce |