summaryrefslogtreecommitdiffstats
path: root/library/tk.tcl
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2023-11-19 19:17:33 (GMT)
committermarc_culler <marc.culler@gmail.com>2023-11-19 19:17:33 (GMT)
commit404383577459f5d77a42386134835beaaa62f164 (patch)
tree26b233cd6d014f0c86313b3bfb0226c185bf0a10 /library/tk.tcl
parentf28d954bfec94579d39e5a1f71363e42066b49c4 (diff)
downloadtk-404383577459f5d77a42386134835beaaa62f164.zip
tk-404383577459f5d77a42386134835beaaa62f164.tar.gz
tk-404383577459f5d77a42386134835beaaa62f164.tar.bz2
Add helper functions to avoid multiple occurrences of hard-wired constants.
Diffstat (limited to 'library/tk.tcl')
-rw-r--r--library/tk.tcl24
1 files changed, 24 insertions, 0 deletions
diff --git a/library/tk.tcl b/library/tk.tcl
index a6dc37c..74942cb 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -543,6 +543,30 @@ proc ::tk::CancelRepeat {} {
set Priv(afterId) {}
}
+
+# ::tk::IsHiResScroll $state --
+# Checks whether the HiResScrollMask bit is set in the state.
+
+proc ::tk::IsHiResScroll state {
+ if {[expr {$state & 512}]} {
+ return 1
+ } else {
+ return 0
+ }
+}
+
+# ::tk::ScrollDirection $state --
+# Checks if ShiftMask is set in the MouseWheelEvent state.
+# Returns h for a horizontal scroll, v for a vertical scroll
+
+proc ::tk::ScrollDirection state {
+ if {[expr {$state & 1}]} {
+ return "h"
+ } else {
+ return "v"
+ }
+}
+
## ::tk::MouseWheel $w $dir $amount $factor $units
proc ::tk::MouseWheel {w dir amount {factor -120.0} {units units}} {