diff options
author | marc_culler <marc.culler@gmail.com> | 2023-11-19 19:17:33 (GMT) |
---|---|---|
committer | marc_culler <marc.culler@gmail.com> | 2023-11-19 19:17:33 (GMT) |
commit | 404383577459f5d77a42386134835beaaa62f164 (patch) | |
tree | 26b233cd6d014f0c86313b3bfb0226c185bf0a10 /library/tk.tcl | |
parent | f28d954bfec94579d39e5a1f71363e42066b49c4 (diff) | |
download | tk-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.tcl | 24 |
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}} { |