From 6c40142971bc757303b36f55caf599bffe6d1d53 Mon Sep 17 00:00:00 2001 From: csaba Date: Mon, 15 Jul 2024 19:41:34 +0000 Subject: [PATCH] Made sure that the TouchpadScroll event bindings won't polluate the global namespace (thanks to Rolf Ade for triggering this improvement). --- library/listbox.tcl | 12 ++++++------ library/scrlbar.tcl | 10 +++++----- library/text.tcl | 10 +++++----- library/ttk/combobox.tcl | 6 +++--- library/ttk/spinbox.tcl | 6 +++--- library/ttk/utils.tcl | 10 +++++----- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/library/listbox.tcl b/library/listbox.tcl index d6118011d..e229cafc2 100644 --- a/library/listbox.tcl +++ b/library/listbox.tcl @@ -14,7 +14,7 @@ # tk::Priv elements used in this file: # # afterId - Token returned by "after" for autoscanning. -# listboxPrev - The last element to be selected or deselected +# listboxPrev - The last element to be selected or deselected # during a selection operation. # listboxSelection - All of the items that were selected before the # current selection operation (such as a mouse @@ -191,12 +191,12 @@ bind Listbox { if {%# %% 5 != 0} { return } - lassign [tk::PreciseScrollDeltas %D] deltaX deltaY - if {$deltaX != 0} { - %W xview scroll [expr {-$deltaX}] units + lassign [tk::PreciseScrollDeltas %D] tk::Priv::deltaX tk::Priv::deltaY + if {$tk::Priv::deltaX != 0} { + %W xview scroll [expr {-$tk::Priv::deltaX}] units } - if {$deltaY != 0} { - %W yview scroll [expr {-$deltaY}] units + if {$tk::Priv::deltaY != 0} { + %W yview scroll [expr {-$tk::Priv::deltaY}] units } } diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index 9e210f665..fd44f107b 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -145,12 +145,12 @@ bind Scrollbar { tk::ScrollByUnits %W hv %D -12.0 } bind Scrollbar { - lassign [tk::PreciseScrollDeltas %D] deltaX deltaY - if {$deltaX != 0 && [%W cget -orient] eq "horizontal"} { - tk::ScrollbarScrollByPixels %W h $deltaX + lassign [tk::PreciseScrollDeltas %D] tk::Priv::deltaX tk::Priv::deltaY + if {$tk::Priv::deltaX != 0 && [%W cget -orient] eq "horizontal"} { + tk::ScrollbarScrollByPixels %W h $tk::Priv::deltaX } - if {$deltaY != 0 && [%W cget -orient] eq "vertical"} { - tk::ScrollbarScrollByPixels %W v $deltaY + if {$tk::Priv::deltaY != 0 && [%W cget -orient] eq "vertical"} { + tk::ScrollbarScrollByPixels %W v $tk::Priv::deltaY } } diff --git a/library/text.tcl b/library/text.tcl index 15bdef21a..5003ade84 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -469,12 +469,12 @@ bind Text { tk::MouseWheel %W x [tk::ScaleNum %D] -1.2 pixels } bind Text { - lassign [tk::PreciseScrollDeltas %D] deltaX deltaY - if {$deltaX != 0} { - %W xview scroll [tk::ScaleNum [expr {-$deltaX}]] pixels + lassign [tk::PreciseScrollDeltas %D] tk::Priv::deltaX tk::Priv::deltaY + if {$tk::Priv::deltaX != 0} { + %W xview scroll [tk::ScaleNum [expr {-$tk::Priv::deltaX}]] pixels } - if {$deltaY != 0} { - %W yview scroll [tk::ScaleNum [expr {-$deltaY}]] pixels + if {$tk::Priv::deltaY != 0} { + %W yview scroll [tk::ScaleNum [expr {-$tk::Priv::deltaY}]] pixels } } diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl index 1b9d4cbdc..649cbd000 100644 --- a/library/ttk/combobox.tcl +++ b/library/ttk/combobox.tcl @@ -57,10 +57,10 @@ bind TCombobox { # Ignore the event } bind TCombobox { - lassign [tk::PreciseScrollDeltas %D] deltaX deltaY + lassign [tk::PreciseScrollDeltas %D] tk::Priv::deltaX tk::Priv::deltaY # TouchpadScroll events fire about 60 times per second. - if {$deltaY != 0 && %# %% 15 == 0} { - ttk::combobox::Scroll %W [expr {$deltaY > 0 ? -1 : 1}] + if {$tk::Priv::deltaY != 0 && %# %% 15 == 0} { + ttk::combobox::Scroll %W [expr {$tk::Priv::deltaY > 0 ? -1 : 1}] } } bind TCombobox <> { ttk::combobox::TraverseIn %W } diff --git a/library/ttk/spinbox.tcl b/library/ttk/spinbox.tcl index 96d8acfe3..c86579557 100644 --- a/library/ttk/spinbox.tcl +++ b/library/ttk/spinbox.tcl @@ -28,10 +28,10 @@ bind TSpinbox { # Ignore the event } bind TSpinbox { - lassign [tk::PreciseScrollDeltas %D] deltaX deltaY + lassign [tk::PreciseScrollDeltas %D] tk::Priv::deltaX tk::Priv::deltaY # TouchpadScroll events fire about 60 times per second. - if {$deltaY != 0 && %# %% 12 == 0} { - ttk::spinbox::Spin %W [expr {$deltaY > 0 ? -1 : 1}] + if {$tk::Priv::deltaY != 0 && %# %% 12 == 0} { + ttk::spinbox::Spin %W [expr {$tk::Priv::deltaY > 0 ? -1 : 1}] } } diff --git a/library/ttk/utils.tcl b/library/ttk/utils.tcl index 3f6446dc1..4b49ae099 100644 --- a/library/ttk/utils.tcl +++ b/library/ttk/utils.tcl @@ -307,12 +307,12 @@ bind TtkScrollable { if {%# %% 5 != 0} { return } - lassign [tk::PreciseScrollDeltas %D] deltaX deltaY - if {$deltaX != 0} { - %W xview scroll [expr {-$deltaX}] units + lassign [tk::PreciseScrollDeltas %D] tk::Priv::deltaX tk::Priv::deltaY + if {$tk::Priv::deltaX != 0} { + %W xview scroll [expr {-$tk::Priv::deltaX}] units } - if {$deltaY != 0} { - %W yview scroll [expr {-$deltaY}] units + if {$tk::Priv::deltaY != 0} { + %W yview scroll [expr {-$tk::Priv::deltaY}] units } } #*EOF*