Menu

#1810 TkAqua:scrolling

obsolete: 8.4.9
closed-fixed
5
2005-06-03
2004-12-12
Anonymous
No

The scrollbars don't move well when linked to objects that have
quantal scrolling (like a text box).
I think this has been a problem with thr Aqua version for a while
now.

Example:
toplevel .t
grid [scrollbar .t.sc -command ".t.txt yview"] -row 1 -column 2
-sticky nws
grid [text .t.txt -yscrollcommand ".t.sc set"] -row 1 -column 1
-sticky nswe
grid rowconfigure .t 1 -weight 1
grid columnconfigure .t 1 -weight 1
.t.txt insert 1.0 [string repeat "a\n" 30]

if you try to drag the scroll moderately slowly up or down, it
doesn't move.

The problem is that each call to the yscrollcommand resets the
stored mouse position, so that each scrolling step is less than the
text moves, so nothing happens.

you can work around this by:
bind .t.sc <Button-1> {set mousedown %Y; set scrollmdown
[lindex [%W get] 0]}
.t.sc configure -command "vertscroll .t"

proc vertscroll {w args} {
global mousedown scrollmdown
if {[lindex $args 0] == "moveto"} {
#catch the moveto- this is mouse movement
#I assume the arrows are at the bottom and ~40pixels high
#the moveto value is the fraction the scrollbar was at when
#the mouse was first clicked plus the fraction the mouse has
# moved

#the fraction the mouse has moved is the difference between
#where the mouse was first clicked and where it is now, divided
#by the length of the scrollbar in pixels.

set moveto [expr {$scrollmdown+(1.0*[winfo pointery .]-
$mousedown)/([winfo height $w.sc]-40)}]
$w.txt yview moveto $moveto
} else {
#all of the other commands are fine
eval [concat $w.txt yview $args]
}
}

now, all is good.

Discussion

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2004-12-13
    • assigned_to: hobbs --> das
     
  • Michael Kirkham

    Michael Kirkham - 2005-05-15

    Logged In: YES
    user_id=498198

    A proper patch to tkMacOSXScrlbr.c can be found in patch #
    1202220.

     
  • Jim Ingham

    Jim Ingham - 2005-06-03
    • status: open --> closed-fixed
     
  • Jim Ingham

    Jim Ingham - 2005-06-03

    Logged In: YES
    user_id=169107

    I commited Michael Kirkham's patch for this. Looks like it resolves this
    issue. There's a comment inthe patch that this has some undesireable
    behavior (when you let the mouse go outside the scroll trough, then back
    in, the scrollbar jumps around). If that's really a problem, a separate bug
    should be filed on that.