[Rd] stuck tcltk scrollbars under Windows XP
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Jun 6 13:46:39 MEST 2003
Duncan Murdoch <dmurdoch at pair.com> writes:
> On Fri, 06 Jun 2003 07:23:27 -0400, you wrote:
>
> >
> >You can test for the problem with the following code:
> ...
> >I find that I can make the scrollbar stick under Windows XP by repeatedly
> >and rapidly pressing the scroll-down button.
>
> I can reproduce it easily in XP in yesterday's 1.7.1 beta.
>
> >I wonder whether anyone else has encountered this problem or has any
> >insight into its source.
>
> I don't know TCL/TK well enough to know what tkgrab does in Windows
> terms, but the general symptoms look as though events are being
> missed. When you click on something messages are generated for
> mouse-down and mouse-up events; it looks as though some mouse-up
> messages are being lost.
We have an old issue on Windows which I haven't had the stamina to dig
into: On Unix, all Tcl event handling is keyed to the keyboard loop.
On Windows, we run a check for Tcl events "every once in a while".
I think it was Brian that implemented the Windows version and it
seemed like a good idea at the time. However, it breaks some things
where Tcl/Tk tends to assume atomic processing. E.g., this is behind
the code in the tkfaq demo (and elsewhere):
txt <- tktext(tt, bg="white", font="courier")
scr <- tkscrollbar(tt, repeatinterval=5,
command=function(...)tkyview(txt,...))
## Safest to make sure scr exists before setting yscrollcommand
tkconfigure(txt, yscrollcommand=function(...)tkset(scr,...))
Where the point is that the text widget will otherwise generate an
event which results in a call to tkset(scr,...), possibly before scr
exists.
In a Tcl script, there is no problem with this and the preferred idiom
is actually
text .tt.txt -command {set .tt.scr}
scrollbar .tt.scr -command {yview .tt.txt}
(although you can't run them like that individually on the wish
command line for the same reason as above).
I.e. Tcl scripts generally expect to run to completion before event
processing takes place. You could be bumping into something similar in
the function that calls tkgrab.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-devel
mailing list