Index: library/scrlbar.tcl ================================================================== --- library/scrlbar.tcl +++ library/scrlbar.tcl @@ -129,20 +129,14 @@ } } if {[tk windowingsystem] eq "aqua"} { bind Scrollbar { - tk::ScrollByUnits %W v [expr {-(%D)}] + tk::ScrollByUnits %W hv [expr {-(%D)}] } bind Scrollbar { - tk::ScrollByUnits %W v [expr {-10 * (%D)}] - } - bind Scrollbar { - tk::ScrollByUnits %W h [expr {-(%D)}] - } - bind Scrollbar { - tk::ScrollByUnits %W h [expr {-10 * (%D)}] + tk::ScrollByUnits %W hv [expr {-10 * (%D)}] } } else { # We must make sure that positive and negative movements are rounded # equally to integers, avoiding the problem that # (int)1/30 = 0, @@ -149,31 +143,22 @@ # but # (int)-1/30 = -1 # The following code ensure equal +/- behaviour. bind Scrollbar { if {%D >= 0} { - tk::ScrollByUnits %W v [expr {-%D/30}] - } else { - tk::ScrollByUnits %W v [expr {(29-%D)/30}] - } - } - bind Scrollbar { - if {%D >= 0} { - tk::ScrollByUnits %W h [expr {-%D/30}] - } else { - tk::ScrollByUnits %W h [expr {(29-%D)/30}] + tk::ScrollByUnits %W hv [expr {-%D/30}] + } else { + tk::ScrollByUnits %W hv [expr {(29-%D)/30}] } } } if {[tk windowingsystem] eq "x11"} { - bind Scrollbar {tk::ScrollByUnits %W v -5} - bind Scrollbar {tk::ScrollByUnits %W v 5} - bind Scrollbar {tk::ScrollByUnits %W h -5} - bind Scrollbar {tk::ScrollByUnits %W h 5} - bind Scrollbar {tk::ScrollByUnits %W h -5} - bind Scrollbar {tk::ScrollByUnits %W h 5} + bind Scrollbar {tk::ScrollByUnits %W hv -5} + bind Scrollbar {tk::ScrollByUnits %W hv 5} + bind Scrollbar {tk::ScrollByUnits %W hv -5} + bind Scrollbar {tk::ScrollByUnits %W hv 5} } # tk::ScrollButtonDown -- # This procedure is invoked when a button is pressed in a scrollbar. # It changes the way the scrollbar is displayed and takes actions Index: library/ttk/scrollbar.tcl ================================================================== --- library/ttk/scrollbar.tcl +++ library/ttk/scrollbar.tcl @@ -19,18 +19,17 @@ # Redirect scrollwheel bindings to the scrollbar widget # # The shift-bindings scroll left/right (not up/down) # if a widget has both possibilities -set eventList [list ] +set eventList [list ] switch [tk windowingsystem] { aqua { - lappend eventList + lappend eventList } x11 { - lappend eventList \ - + lappend eventList } } foreach event $eventList { bind TScrollbar $event [bind Scrollbar $event] } Index: tests/scrollbar.test ================================================================== --- tests/scrollbar.test +++ tests/scrollbar.test @@ -712,11 +712,11 @@ .t index @0,0 } -cleanup { destroy .t .s } -result {5.0} -test scrollbar-10.2.1 { event on scrollbar} -constraints {notAqua} -setup { +test scrollbar-10.2.1 { event on horizontal scrollbar} -constraints {notAqua} -setup { destroy .t .s } -body { pack [text .t -xscrollcommand {.s set} -wrap none] -side top for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top @@ -726,11 +726,11 @@ after 200 {set eventprocessed 1} ; vwait eventprocessed .t index @0,0 } -cleanup { destroy .t .s } -result {1.4} -test scrollbar-10.2.2 { event on scrollbar} -constraints {aqua} -setup { +test scrollbar-10.2.2 { event on horizontal scrollbar} -constraints {aqua} -setup { destroy .t .s } -body { pack [text .t -xscrollcommand {.s set} -wrap none] -side top for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top @@ -737,10 +737,38 @@ update focus -force .s event generate .s -delta -4 after 200 {set eventprocessed 1} ; vwait eventprocessed .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.3 { event on horizontal scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.4 { event on horizontal scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 } -cleanup { destroy .t .s } -result {1.4} test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { Index: tests/ttk/scrollbar.test ================================================================== --- tests/ttk/scrollbar.test +++ tests/ttk/scrollbar.test @@ -67,10 +67,96 @@ wm geometry . 200x200 update set w [winfo width .tsb] ; set h [winfo height .tsb] expr {$h < $w} } -result 1 + +test scrollbar-10.1.1 { event on scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [ttk::scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} +test scrollbar-10.1.2 { event on scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [ttk::scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} + +test scrollbar-10.2.1 { event on horizontal scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.2 { event on horizontal scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.3 { event on horizontal scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.4 { event on horizontal scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} # # Scale tests: #