From 68fc0a0ef4781d53802b28f569935acedc875a92 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 22 Aug 2019 15:29:53 +0000 Subject: Use some more "(x|y)view scroll units" automatic rounding in bindings. --- library/demos/cscroll.tcl | 15 ++++++++++++++- library/iconlist.tcl | 6 +----- library/listbox.tcl | 8 ++++---- library/ttk/utils.tcl | 8 ++++---- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl index 7bbb91c..1740f94 100644 --- a/library/demos/cscroll.tcl +++ b/library/demos/cscroll.tcl @@ -58,7 +58,20 @@ $c bind all "scrollLeave $c" $c bind all <1> "scrollButton $c" bind $c <2> "$c scan mark %x %y" bind $c "$c scan dragto %x %y" -if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { +if {[package vsatisfies [package provide Tk] 8.7-]} { + bind $c { + %W yview scroll [expr {%D/-30.0}] units + } + bind $c { + %W yview scroll [expr {%D/-3.0}] units + } + bind $c { + %W xview scroll [expr {%D/-30.0}] units + } + bind $c { + %W xview scroll [expr {%D/-3.0}] units + } +} elseif {[tk windowingsystem] eq "aqua"} { bind $c { %W yview scroll [expr {-(%D)}] units } diff --git a/library/iconlist.tcl b/library/iconlist.tcl index 30352a1..65c66b1 100644 --- a/library/iconlist.tcl +++ b/library/iconlist.tcl @@ -509,11 +509,7 @@ package require Tk 8.6 if {$noScroll || $::tk_strictMotif} { return } - if {$amount > 0} { - $canvas xview scroll [expr {(-119-$amount) / 120}] units - } else { - $canvas xview scroll [expr {-($amount / 120)}] units - } + $canvas xview scroll [expr {$amount/-120.0}] units } method Btn1 {x y} { focus $canvas diff --git a/library/listbox.tcl b/library/listbox.tcl index 7400494..500c32e 100644 --- a/library/listbox.tcl +++ b/library/listbox.tcl @@ -177,16 +177,16 @@ bind Listbox { } bind Listbox { - %W yview scroll [expr {%D/-30}] units + %W yview scroll [expr {%D/-30.0}] units } bind Listbox { - %W yview scroll [expr {%D/-3}] units + %W yview scroll [expr {%D/-3.0}] units } bind Listbox { - %W xview scroll [expr {%D/-30}] units + %W xview scroll [expr {%D/-30.0}] units } bind Listbox { - %W xview scroll [expr {%D/-3}] units + %W xview scroll [expr {%D/-3.0}] units } # ::tk::ListboxBeginSelect -- diff --git a/library/ttk/utils.tcl b/library/ttk/utils.tcl index 4827aa3..3729254 100644 --- a/library/ttk/utils.tcl +++ b/library/ttk/utils.tcl @@ -298,12 +298,12 @@ proc ttk::bindMouseWheel {bindtag callback} { # bind TtkScrollable \ - { %W yview scroll [expr {%D/-120}] units } + { %W yview scroll [expr {%D/-120.0}] units } bind TtkScrollable \ - { %W yview scroll [expr {%D/-12}] units } + { %W yview scroll [expr {%D/-12.0}] units } bind TtkScrollable \ - { %W xview scroll [expr {%D/-120}] units } + { %W xview scroll [expr {%D/-120.0}] units } bind TtkScrollable \ - { %W xview scroll [expr {%D/-12}] units } + { %W xview scroll [expr {%D/-12.0}] units } #*EOF* -- cgit v0.12