summaryrefslogtreecommitdiffstats
path: root/library/ttk
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2023-11-27 20:21:17 (GMT)
committermarc_culler <marc.culler@gmail.com>2023-11-27 20:21:17 (GMT)
commit1b1276420e9016d6eddf1cfc49642a0ffcf3535f (patch)
treee3e7b1835316bcce63dccb89fda94747e65c7439 /library/ttk
parent365c1aa8200f8ca770202b571eee7cc324531c77 (diff)
downloadtk-1b1276420e9016d6eddf1cfc49642a0ffcf3535f.zip
tk-1b1276420e9016d6eddf1cfc49642a0ffcf3535f.tar.gz
tk-1b1276420e9016d6eddf1cfc49642a0ffcf3535f.tar.bz2
Adapt Csaba's notebook bindings to the new setup.
Diffstat (limited to 'library/ttk')
-rw-r--r--library/ttk/notebook.tcl28
1 files changed, 28 insertions, 0 deletions
diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl
index 7097c45..21a33b8 100644
--- a/library/ttk/notebook.tcl
+++ b/library/ttk/notebook.tcl
@@ -17,6 +17,16 @@ bind TNotebook <Control-ISO_Left_Tab> { ttk::notebook::CycleTab %W -1; break }
bind TNotebook <Destroy> { ttk::notebook::Cleanup %W }
ttk::bindMouseWheel TNotebook [list ttk::notebook::CycleTab %W]
+bind TNotebook <Shift-MouseWheel> {
+ # Ignore the event
+}
+bind TNotebook <TouchpadScroll> {
+ lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
+ # TouchpadScroll events fire about 60 times per second.
+ if {$deltaX != 0 && [expr {%# %% 30}] == 0} {
+ ttk::notebook::CondCycleTab %W %D
+ }
+}
# ActivateTab $nb $tab --
# Select the specified tab and set focus.
@@ -75,6 +85,24 @@ proc ttk::notebook::CycleTab {w dir {factor 1.0}} {
}
}
+# CondCycleTab --
+# Conditionally invoke the ttk::notebook::CycleTab proc.
+#
+proc ttk::notebook::CondCycleTab {w dxdy} {
+ if {[set style [$w cget -style]] eq ""} {
+ set style TNotebook
+ }
+ set tabSide [string index [ttk::style lookup $style -tabposition {} nw] 0]
+
+ lassign [tk::PreciseScrollDeltas $dxdy] deltaX deltaY
+ if {$tabSide in {n s} && $deltaX != 0} {
+ CycleTab $w [expr {$deltaX > 0 ? -1 : 1}]
+ }
+ if {$tabSide in {w e} && $deltaY != 0} {
+ CycleTab $w [expr {$deltaY > 0 ? -1 : 1}]
+ }
+}
+
# MnemonicTab $nb $key --
# Scan all tabs in the specified notebook for one with the
# specified mnemonic. If found, returns path name of tab;