diff options
Diffstat (limited to 'library')
-rw-r--r-- | library/demos/cscroll.tcl | 40 | ||||
-rw-r--r-- | library/demos/ctext.tcl | 2 | ||||
-rw-r--r-- | library/demos/floor.tcl | 2 | ||||
-rw-r--r-- | library/demos/items.tcl | 2 | ||||
-rw-r--r-- | library/entry.tcl | 25 | ||||
-rw-r--r-- | library/iconlist.tcl | 29 | ||||
-rw-r--r-- | library/listbox.tcl | 84 | ||||
-rw-r--r-- | library/scale.tcl | 8 | ||||
-rw-r--r-- | library/scrlbar.tcl | 37 | ||||
-rw-r--r-- | library/spinbox.tcl | 27 | ||||
-rw-r--r-- | library/systray.tcl | 12 | ||||
-rw-r--r-- | library/tclIndex | 1 | ||||
-rw-r--r-- | library/text.tcl | 112 | ||||
-rw-r--r-- | library/tk.tcl | 16 | ||||
-rw-r--r-- | library/ttk/combobox.tcl | 8 | ||||
-rw-r--r-- | library/ttk/entry.tcl | 16 | ||||
-rw-r--r-- | library/ttk/scrollbar.tcl | 17 | ||||
-rw-r--r-- | library/ttk/spinbox.tcl | 6 | ||||
-rw-r--r-- | library/ttk/utils.tcl | 81 |
19 files changed, 116 insertions, 409 deletions
diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl index f906c7d..d210c7d 100644 --- a/library/demos/cscroll.tcl +++ b/library/demos/cscroll.tcl @@ -56,29 +56,29 @@ for {set i 0} {$i < 20} {incr i} { $c bind all <Enter> "scrollEnter $c" $c bind all <Leave> "scrollLeave $c" $c bind all <Button-1> "scrollButton $c" -if {[tk windowingsystem] eq "aqua"} { +if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk] 8.7-]} { bind $c <Button-3> "$c scan mark %x %y" bind $c <B3-Motion> "$c scan dragto %x %y" bind $c <MouseWheel> { - %W yview scroll [expr {-(%D)}] units + %W yview scroll [expr {-%D}] units } bind $c <Option-MouseWheel> { - %W yview scroll [expr {-10 * (%D)}] units + %W yview scroll [expr {-10*%D}] units } bind $c <Shift-MouseWheel> { - %W xview scroll [expr {-(%D)}] units + %W xview scroll [expr {-%D}] units } bind $c <Shift-Option-MouseWheel> { - %W xview scroll [expr {-10 * (%D)}] units + %W xview scroll [expr {-10*%D}] units } } else { bind $c <Button-2> "$c scan mark %x %y" bind $c <B2-Motion> "$c scan dragto %x %y" # We must make sure that positive and negative movements are rounded # equally to integers, avoiding the problem that - # (int)1/30 = 0, + # (int)1/-30 = -1, # but - # (int)-1/30 = -1 + # (int)-1/-30 = 0 # The following code ensure equal +/- behaviour. bind $c <MouseWheel> { if {%D >= 0} { @@ -88,7 +88,11 @@ if {[tk windowingsystem] eq "aqua"} { } } bind $c <Option-MouseWheel> { - %W yview scroll [expr {%D/-3}] units + if {%D >= 0} { + %W yview scroll [expr {%D/-3}] units + } else { + %W yview scroll [expr {(%D-2)/-3}] units + } } bind $c <Shift-MouseWheel> { if {%D >= 0} { @@ -98,11 +102,15 @@ if {[tk windowingsystem] eq "aqua"} { } } bind $c <Shift-Option-MouseWheel> { - %W xview scroll [expr {%D/-3}] units + if {%D >= 0} { + %W xview scroll [expr {%D/-3}] units + } else { + %W xview scroll [expr {(%D-2)/-3}] units + } } } -if {[tk windowingsystem] eq "x11"} { +if {[tk windowingsystem] eq "x11" && ![package vsatisfies [package provide Tk] 8.7-]} { # Support for mousewheels on Linux/Unix commonly comes through mapping # the wheel to the extended buttons. If you have a mousewheel, find # Linux configuration info at: @@ -127,18 +135,6 @@ if {[tk windowingsystem] eq "x11"} { %W xview scroll 5 units } } - if {[package vsatisfies [package provide Tk] 8.7]} { - bind $c <Button-6> { - if {!$tk_strictMotif} { - %W xview scroll -5 units - } - } - bind $c <Button-7> { - if {!$tk_strictMotif} { - %W xview scroll 5 units - } - } - } } diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl index 5acc82f..d3fec33 100644 --- a/library/demos/ctext.tcl +++ b/library/demos/ctext.tcl @@ -50,7 +50,7 @@ $c bind text <Return> "textInsert $c \\n" $c bind text <Control-h> "textBs $c" $c bind text <BackSpace> "textBs $c" $c bind text <Delete> "textDel $c" -if {[tk windowingsystem] eq "aqua"} { +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { $c bind text <Button-3> "textPaste $c @%x,%y" } else { $c bind text <Button-2> "textPaste $c @%x,%y" diff --git a/library/demos/floor.tcl b/library/demos/floor.tcl index 37e1b95..eb2ea7f 100644 --- a/library/demos/floor.tcl +++ b/library/demos/floor.tcl @@ -1359,7 +1359,7 @@ $c bind floor2 <Button-1> "floorDisplay $c 2" $c bind floor3 <Button-1> "floorDisplay $c 3" $c bind room <Enter> "newRoom $c" $c bind room <Leave> {set currentRoom ""} -if {[tk windowingsystem] eq "aqua"} { +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { bind $c <Button-3> "$c scan mark %x %y" bind $c <B3-Motion> "$c scan dragto %x %y" } else { diff --git a/library/demos/items.tcl b/library/demos/items.tcl index 545877c..1297046 100644 --- a/library/demos/items.tcl +++ b/library/demos/items.tcl @@ -173,7 +173,7 @@ $c create text 28.5c 17.4c -text Scale: -anchor s $c bind item <Enter> "itemEnter $c" $c bind item <Leave> "itemLeave $c" -if {[tk windowingsystem] eq "aqua"} { +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { bind $c <Button-2> "itemMark $c %x %y" bind $c <B2-Motion> "itemStroke $c %x %y" bind $c <Button-3> "$c scan mark %x %y" diff --git a/library/entry.tcl b/library/entry.tcl index 6539af7..f95d6bd 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -293,28 +293,15 @@ bind Entry <<TkAccentBackspace>> { # A few additional bindings of my own. -if {[tk windowingsystem] ne "aqua"} { - bind Entry <Button-2> { - if {!$tk_strictMotif} { - ::tk::EntryScanMark %W %x - } - } - bind Entry <B2-Motion> { - if {!$tk_strictMotif} { - ::tk::EntryScanDrag %W %x - } - } -} else { - bind Entry <Button-3> { - if {!$tk_strictMotif} { +bind Entry <Button-2> { + if {!$tk_strictMotif} { ::tk::EntryScanMark %W %x - } } - bind Entry <B3-Motion> { - if {!$tk_strictMotif} { +} +bind Entry <B2-Motion> { + if {!$tk_strictMotif} { ::tk::EntryScanDrag %W %x - } - } + } } # ::tk::EntryClosestGap -- diff --git a/library/iconlist.tcl b/library/iconlist.tcl index a19dbeb..c052efb 100644 --- a/library/iconlist.tcl +++ b/library/iconlist.tcl @@ -446,18 +446,9 @@ package require Tk bind $canvas <Control-B1-Motion> {;} bind $canvas <Shift-B1-Motion> [namespace code {my ShiftMotion1 %x %y}] - if {[tk windowingsystem] eq "aqua"} { - bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel [expr {40 * (%D)}]}] - bind $canvas <Option-Shift-MouseWheel> [namespace code {my MouseWheel [expr {400 * (%D)}]}] - } else { - bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel %D}] - } - if {[tk windowingsystem] eq "x11"} { - bind $canvas <Shift-Button-4> [namespace code {my MouseWheel 120}] - bind $canvas <Shift-Button-5> [namespace code {my MouseWheel -120}] - bind $canvas <Button-6> [namespace code {my MouseWheel 120}] - bind $canvas <Button-7> [namespace code {my MouseWheel -120}] - } + bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel %D}] + bind $canvas <Option-Shift-MouseWheel> [namespace code {my MouseWheel %D -12}] + bind $canvas <<PrevLine>> [namespace code {my UpDown -1}] bind $canvas <<NextLine>> [namespace code {my UpDown 1}] @@ -505,21 +496,11 @@ package require Tk # ---------------------------------------------------------------------- # Event handlers - method MouseWheel {amount} { + method MouseWheel {amount {factor -120.0}} { if {$noScroll || $::tk_strictMotif} { return } - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/120 = 0, - # but - # (int)-1/120 = -1 - # The following code ensure equal +/- behaviour. - if {$amount > 0} { - $canvas xview scroll [expr {(-119-$amount) / 120}] units - } else { - $canvas xview scroll [expr {-($amount / 120)}] units - } + $canvas xview scroll [expr {$amount/$factor}] units } method Btn1 {x y} { focus $canvas diff --git a/library/listbox.tcl b/library/listbox.tcl index bf40a39..ffedee6 100644 --- a/library/listbox.tcl +++ b/library/listbox.tcl @@ -176,81 +176,17 @@ bind Listbox <B2-Motion> { %W scan dragto %x %y } -# The MouseWheel will typically only fire on Windows and Mac OS X. -# However, someone could use the "event generate" command to produce -# one on other platforms. - -if {[tk windowingsystem] eq "aqua"} { - bind Listbox <MouseWheel> { - %W yview scroll [expr {-(%D)}] units - } - bind Listbox <Option-MouseWheel> { - %W yview scroll [expr {-10 * (%D)}] units - } - bind Listbox <Shift-MouseWheel> { - %W xview scroll [expr {-(%D)}] units - } - bind Listbox <Shift-Option-MouseWheel> { - %W xview scroll [expr {-10 * (%D)}] units - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/30 = 0, - # but - # (int)-1/30 = -1 - # The following code ensure equal +/- behaviour. - bind Listbox <MouseWheel> { - if {%D >= 0} { - %W yview scroll [expr {-%D/30}] units - } else { - %W yview scroll [expr {(29-%D)/30}] units - } - } - bind Listbox <Shift-MouseWheel> { - if {%D >= 0} { - %W xview scroll [expr {-%D/30}] units - } else { - %W xview scroll [expr {(29-%D)/30}] units - } - } +bind Listbox <MouseWheel> { + tk::MouseWheel %W y %D -30.0 } - -if {[tk windowingsystem] eq "x11"} { - # Support for mousewheels on Linux/Unix commonly comes through mapping - # the wheel to the extended buttons. If you have a mousewheel, find - # Linux configuration info at: - # http://linuxreviews.org/howtos/xfree/mouse/ - bind Listbox <Button-4> { - if {!$tk_strictMotif} { - %W yview scroll -5 units - } - } - bind Listbox <Shift-Button-4> { - if {!$tk_strictMotif} { - %W xview scroll -5 units - } - } - bind Listbox <Button-5> { - if {!$tk_strictMotif} { - %W yview scroll 5 units - } - } - bind Listbox <Shift-Button-5> { - if {!$tk_strictMotif} { - %W xview scroll 5 units - } - } - bind Listbox <Button-6> { - if {!$tk_strictMotif} { - %W xview scroll -5 units - } - } - bind Listbox <Button-7> { - if {!$tk_strictMotif} { - %W xview scroll 5 units - } - } +bind Listbox <Option-MouseWheel> { + tk::MouseWheel %W y %D -3.0 +} +bind Listbox <Shift-MouseWheel> { + tk::MouseWheel %W x %D -30.0 +} +bind Listbox <Shift-Option-MouseWheel> { + tk::MouseWheel %W x %D -3.0 } # ::tk::ListboxBeginSelect -- diff --git a/library/scale.tcl b/library/scale.tcl index cc0de20..130c491 100644 --- a/library/scale.tcl +++ b/library/scale.tcl @@ -60,14 +60,6 @@ bind Scale <ButtonRelease-2> { tk::ScaleEndDrag %W tk::ScaleActivate %W %x %y } -if {[tk windowingsystem] eq "win32"} { - # On Windows do the same with button 3, as that is the right mouse button - bind Scale <Button-3> [bind Scale <Button-2>] - bind Scale <B3-Motion> [bind Scale <B2-Motion>] - bind Scale <B3-Leave> [bind Scale <B2-Leave>] - bind Scale <B3-Enter> [bind Scale <B2-Enter>] - bind Scale <ButtonRelease-3> [bind Scale <ButtonRelease-2>] -} bind Scale <Control-Button-1> { tk::ScaleControlPress %W %x %y } diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index 8106b3d..f545785 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -129,34 +129,11 @@ bind Scrollbar <<LineEnd>> { } } -if {[tk windowingsystem] eq "aqua"} { - bind Scrollbar <MouseWheel> { - tk::ScrollByUnits %W hv [expr {-(%D)}] - } - bind Scrollbar <Option-MouseWheel> { - tk::ScrollByUnits %W hv [expr {-10 * (%D)}] - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/30 = 0, - # but - # (int)-1/30 = -1 - # The following code ensure equal +/- behaviour. - bind Scrollbar <MouseWheel> { - if {%D >= 0} { - tk::ScrollByUnits %W hv [expr {-%D/30}] - } else { - tk::ScrollByUnits %W hv [expr {(29-%D)/30}] - } - } +bind Scrollbar <MouseWheel> { + tk::ScrollByUnits %W hv %D -30.0 } - -if {[tk windowingsystem] eq "x11"} { - bind Scrollbar <Button-4> {tk::ScrollByUnits %W hv -5} - bind Scrollbar <Button-5> {tk::ScrollByUnits %W hv 5} - bind Scrollbar <Button-6> {tk::ScrollByUnits %W hv -5} - bind Scrollbar <Button-7> {tk::ScrollByUnits %W hv 5} +bind Scrollbar <Option-MouseWheel> { + tk::ScrollByUnits %W hv %D -3.0 } # tk::ScrollButtonDown -- @@ -329,7 +306,7 @@ proc ::tk::ScrollEndDrag {w x y} { # horizontal, "v" for vertical, "hv" for both. # amount - How many units to scroll: typically 1 or -1. -proc ::tk::ScrollByUnits {w orient amount} { +proc ::tk::ScrollByUnits {w orient amount {factor 1.0}} { set cmd [$w cget -command] if {$cmd eq "" || ([string first \ [string index [$w cget -orient] 0] $orient] < 0)} { @@ -337,9 +314,9 @@ proc ::tk::ScrollByUnits {w orient amount} { } set info [$w get] if {[llength $info] == 2} { - uplevel #0 $cmd scroll $amount units + uplevel #0 $cmd scroll [expr {$amount/$factor}] units } else { - uplevel #0 $cmd [expr {[lindex $info 2] + $amount}] + uplevel #0 $cmd [expr {[lindex $info 2] + [expr {$amount/$factor}]}] } } diff --git a/library/spinbox.tcl b/library/spinbox.tcl index 6ba7842..938e409 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -280,27 +280,14 @@ bind Spinbox <Meta-Delete> { # A few additional bindings of my own. -if {[tk windowingsystem] ne "aqua"} { - bind Spinbox <Button-2> { - if {!$tk_strictMotif} { - ::tk::EntryScanMark %W %x - } - } - bind Spinbox <B2-Motion> { - if {!$tk_strictMotif} { - ::tk::EntryScanDrag %W %x - } - } -} else { - bind Spinbox <Button-3> { - if {!$tk_strictMotif} { - ::tk::EntryScanMark %W %x - } +bind Spinbox <Button-2> { + if {!$tk_strictMotif} { + ::tk::EntryScanMark %W %x } - bind Spinbox <B3-Motion> { - if {!$tk_strictMotif} { - ::tk::EntryScanDrag %W %x - } +} +bind Spinbox <B2-Motion> { + if {!$tk_strictMotif} { + ::tk::EntryScanDrag %W %x } } diff --git a/library/systray.tcl b/library/systray.tcl index 8306194..fb21d2d 100644 --- a/library/systray.tcl +++ b/library/systray.tcl @@ -56,7 +56,7 @@ namespace eval ::winicoprops { } proc _win_callback {msg icn} { - + switch -exact -- $msg { WM_LBUTTONDOWN { eval $::winicoprops::cb1 @@ -168,7 +168,7 @@ proc ::tk::systray {args} { #Set variables for icon properties. global _iconlist - + #Remove the systray icon. if {[lindex $args 0] eq "destroy" && [llength $args] == 1} { @@ -199,11 +199,11 @@ proc ::tk::systray {args} { set _txt [lindex $args 2] set _cb_1 [lindex $args 3] set _cb_3 [lindex $args 4] - + set ::winicoprops::img $_img set ::winicoprops::txt $_txt set ::winicoprops::cb1 $_cb_1 - set ::winicoprops::cb3 $_cb_3 + set ::winicoprops::cb3 $_cb_3 switch -- [tk windowingsystem] { "win32" { if {[llength $_iconlist] > 0} { @@ -257,7 +257,7 @@ proc ::tk::systray {args} { set ::winicoprops::cb3 $_cb_3 _systray taskbar modify $::winicoprops::ico -callback [list _win_callback %m %i] } - + } "x11" { if {[lindex $args 1] eq "image"} { @@ -335,7 +335,7 @@ proc ::tk::sysnotify {title message} { } #Add these commands to the tk command ensemble: tk systray, tk sysnotify -#Thanks to Christian Gollwitzer for the guidance here +#Thanks to Christian Gollwitzer for the guidance here set map [namespace ensemble configure tk -map] dict set map systray ::tk::systray dict set map sysnotify ::tk::sysnotify diff --git a/library/tclIndex b/library/tclIndex index 919fa8a..06006cd 100644 --- a/library/tclIndex +++ b/library/tclIndex @@ -199,6 +199,7 @@ set auto_index(::tk::RestoreFocusGrab) [list source [file join $dir tk.tcl]] set auto_index(::tk::ScreenChanged) [list source [file join $dir tk.tcl]] set auto_index(::tk::EventMotifBindings) [list source [file join $dir tk.tcl]] set auto_index(::tk::CancelRepeat) [list source [file join $dir tk.tcl]] +set auto_index(::tk::MouseWheel) [list source [file join $dir tk.tcl]] set auto_index(::tk::TabToWindow) [list source [file join $dir tk.tcl]] set auto_index(::tk::dialog::file::) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::Config) [list source [file join $dir tkfbox.tcl]] diff --git a/library/text.tcl b/library/text.tcl index a84ea05..00806f7 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -429,107 +429,29 @@ bind Text <Control-h> { %W see insert } } -if {[tk windowingsystem] ne "aqua"} { - bind Text <Button-2> { - if {!$tk_strictMotif} { - tk::TextScanMark %W %x %y - } - } - bind Text <B2-Motion> { - if {!$tk_strictMotif} { - tk::TextScanDrag %W %x %y - } - } -} else { - bind Text <Button-3> { - if {!$tk_strictMotif} { - tk::TextScanMark %W %x %y - } +bind Text <Button-2> { + if {!$tk_strictMotif} { + tk::TextScanMark %W %x %y } - bind Text <B3-Motion> { - if {!$tk_strictMotif} { - tk::TextScanDrag %W %x %y - } +} +bind Text <B2-Motion> { + if {!$tk_strictMotif} { + tk::TextScanDrag %W %x %y } } set ::tk::Priv(prevPos) {} -# The MouseWheel will typically only fire on Windows and MacOS X. -# However, someone could use the "event generate" command to produce one -# on other platforms. We must be careful not to round -ve values of %D -# down to zero. - -if {[tk windowingsystem] eq "aqua"} { - bind Text <MouseWheel> { - %W yview scroll [expr {-15 * (%D)}] pixels - } - bind Text <Option-MouseWheel> { - %W yview scroll [expr {-150 * (%D)}] pixels - } - bind Text <Shift-MouseWheel> { - %W xview scroll [expr {-15 * (%D)}] pixels - } - bind Text <Shift-Option-MouseWheel> { - %W xview scroll [expr {-150 * (%D)}] pixels - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/3 = 0, - # but - # (int)-1/3 = -1 - # The following code ensure equal +/- behaviour. - bind Text <MouseWheel> { - if {%D >= 0} { - %W yview scroll [expr {-%D/3}] pixels - } else { - %W yview scroll [expr {(2-%D)/3}] pixels - } - } - bind Text <Shift-MouseWheel> { - if {%D >= 0} { - %W xview scroll [expr {-%D/3}] pixels - } else { - %W xview scroll [expr {(2-%D)/3}] pixels - } - } +bind Text <MouseWheel> { + tk::MouseWheel y %D -3.0 pixels } - -if {[tk windowingsystem] eq "x11"} { - # Support for mousewheels on Linux/Unix commonly comes through mapping - # the wheel to the extended buttons. If you have a mousewheel, find - # Linux configuration info at: - # http://linuxreviews.org/howtos/xfree/mouse/ - bind Text <Button-4> { - if {!$tk_strictMotif} { - %W yview scroll -50 pixels - } - } - bind Text <Button-5> { - if {!$tk_strictMotif} { - %W yview scroll 50 pixels - } - } - bind Text <Shift-Button-4> { - if {!$tk_strictMotif} { - %W xview scroll -50 pixels - } - } - bind Text <Shift-Button-5> { - if {!$tk_strictMotif} { - %W xview scroll 50 pixels - } - } - bind Text <Button-6> { - if {!$tk_strictMotif} { - %W xview scroll -50 pixels - } - } - bind Text <Button-7> { - if {!$tk_strictMotif} { - %W xview scroll 50 pixels - } - } +bind Text <Option-MouseWheel> { + tk::MouseWheel y %D -0.3 pixels +} +bind Text <Shift-MouseWheel> { + tk::MouseWheel x %D -3.0 pixels +} +bind Text <Shift-Option-MouseWheel> { + tk::MouseWheel x %D -0.3 pixels } # ::tk::TextClosestGap -- diff --git a/library/tk.tcl b/library/tk.tcl index 07ca5be..9328820 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -366,15 +366,16 @@ if {![llength [info command tk_chooseDirectory]]} { # Define the set of common virtual events. #---------------------------------------------------------------------- +event add <<ContextMenu>> <Button-3> +event add <<PasteSelection>> <ButtonRelease-2> + switch -exact -- [tk windowingsystem] { "x11" { event add <<Cut>> <Control-x> <F20> <Control-Lock-X> event add <<Copy>> <Control-c> <F16> <Control-Lock-C> event add <<Paste>> <Control-v> <F18> <Control-Lock-V> - event add <<PasteSelection>> <ButtonRelease-2> event add <<Undo>> <Control-z> <Control-Lock-Z> event add <<Redo>> <Control-Z> <Control-Lock-z> - event add <<ContextMenu>> <Button-3> # On Darwin/Aqua, buttons from left to right are 1,3,2. On Darwin/X11 with recent # XQuartz as the X server, they are 1,2,3; other X servers may differ. @@ -422,10 +423,8 @@ switch -exact -- [tk windowingsystem] { event add <<Cut>> <Control-x> <Shift-Delete> <Control-Lock-X> event add <<Copy>> <Control-c> <Control-Insert> <Control-Lock-C> event add <<Paste>> <Control-v> <Shift-Insert> <Control-Lock-V> - event add <<PasteSelection>> <ButtonRelease-2> event add <<Undo>> <Control-z> <Control-Lock-Z> event add <<Redo>> <Control-y> <Control-Lock-Y> - event add <<ContextMenu>> <Button-3> event add <<SelectAll>> <Control-slash> <Control-a> <Control-Lock-A> event add <<SelectNone>> <Control-backslash> @@ -455,9 +454,7 @@ switch -exact -- [tk windowingsystem] { event add <<Cut>> <Command-x> <F2> <Command-Lock-X> event add <<Copy>> <Command-c> <F3> <Command-Lock-C> event add <<Paste>> <Command-v> <F4> <Command-Lock-V> - event add <<PasteSelection>> <ButtonRelease-3> event add <<Clear>> <Clear> - event add <<ContextMenu>> <Button-2> # Official bindings # See http://support.apple.com/kb/HT1343 @@ -537,6 +534,13 @@ proc ::tk::CancelRepeat {} { set Priv(afterId) {} } +## ::tk::MouseWheel $w $dir $amount $factor $units + +proc ::tk::MouseWheel {w dir amount {factor -120.0} {units units}} { + $w ${dir}view scroll [expr {$amount/$factor}] $units +} + + # ::tk::TabToWindow -- # This procedure moves the focus to the given widget. # It sends a <<TraverseOut>> virtual event to the previous focus window, diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl index 0a7e519..58df760 100644 --- a/library/ttk/combobox.tcl +++ b/library/ttk/combobox.tcl @@ -182,11 +182,15 @@ proc ttk::combobox::SelectEntry {cb index} { ## Scroll -- Mousewheel binding # -proc ttk::combobox::Scroll {cb dir} { +proc ttk::combobox::Scroll {cb dir {factor 1.0}} { $cb instate disabled { return } set max [llength [$cb cget -values]] set current [$cb current] - incr current $dir + set d [expr {round($dir/factor)}] + if {$d == 0 && $dir != 0} { + if {$dir > 0} {set d 1} else {set d -1} + } + incr current $d if {$max != 0 && $current == $current % $max} { SelectEntry $cb $current } diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 2f3c1a6..a4528fa 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -82,20 +82,14 @@ bind TEntry <<ToggleSelection>> { %W instate {!readonly !disabled} { %W icursor @%x ; focus %W } } -## Button2 (Button3 on Aqua) bindings: +## Button2 bindings: # Used for scanning and primary transfer. -# Note: ButtonRelease-2 (ButtonRelease-3 on Aqua) +# Note: ButtonRelease-2 # is mapped to <<PasteSelection>> in tk.tcl. # -if {[tk windowingsystem] ne "aqua"} { - bind TEntry <Button-2> { ttk::entry::ScanMark %W %x } - bind TEntry <B2-Motion> { ttk::entry::ScanDrag %W %x } - bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x } -} else { - bind TEntry <Button-3> { ttk::entry::ScanMark %W %x } - bind TEntry <B3-Motion> { ttk::entry::ScanDrag %W %x } - bind TEntry <ButtonRelease-3> { ttk::entry::ScanRelease %W %x } -} +bind TEntry <Button-2> { ttk::entry::ScanMark %W %x } +bind TEntry <B2-Motion> { ttk::entry::ScanDrag %W %x } +bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x } bind TEntry <<PasteSelection>> { ttk::entry::ScanRelease %W %x } ## Keyboard navigation bindings: diff --git a/library/ttk/scrollbar.tcl b/library/ttk/scrollbar.tcl index fdba265..8f6cf64 100644 --- a/library/ttk/scrollbar.tcl +++ b/library/ttk/scrollbar.tcl @@ -19,21 +19,8 @@ bind TScrollbar <ButtonRelease-2> { ttk::scrollbar::Release %W %x %y } # Redirect scrollwheel bindings to the scrollbar widget # -# The shift-bindings scroll left/right (not up/down) -# if a widget has both possibilities -set eventList [list <MouseWheel>] -switch [tk windowingsystem] { - aqua { - lappend eventList <Option-MouseWheel> - } - x11 { - lappend eventList <Button-4> <Button-5> <Button-6> <Button-7> - } -} -foreach event $eventList { - bind TScrollbar $event [bind Scrollbar $event] -} -unset eventList event +bind TScrollbar <MouseWheel> [bind Scrollbar <MouseWheel>] +bind TScrollbar <Option-MouseWheel> [bind Scrollbar <Option-MouseWheel>] proc ttk::scrollbar::Scroll {w n units} { set cmd [$w cget -command] diff --git a/library/ttk/spinbox.tcl b/library/ttk/spinbox.tcl index 8aba5e1..f580a21 100644 --- a/library/ttk/spinbox.tcl +++ b/library/ttk/spinbox.tcl @@ -82,11 +82,11 @@ proc ttk::spinbox::Release {w} { # Mousewheel callback. Turn these into <<Increment>> (-1, up) # or <<Decrement> (+1, down) events. # -proc ttk::spinbox::MouseWheel {w dir} { +proc ttk::spinbox::MouseWheel {w dir {factor 1}} { if {[$w instate disabled]} { return } - if {$dir < 0} { + if {($dir < 0) ^ ($factor < 0)} { event generate $w <<Increment>> - } else { + } elseif {$dir > 0} { event generate $w <<Decrement>> } } diff --git a/library/ttk/utils.tcl b/library/ttk/utils.tcl index 79e6ce2..181c208 100644 --- a/library/ttk/utils.tcl +++ b/library/ttk/utils.tcl @@ -273,18 +273,6 @@ proc ttk::copyBindings {from to} { # # Platform inconsistencies: # -# On X11, the server typically maps the mouse wheel to Button4 and Button5. -# -# On OSX, Tk generates sensible values for the %D field in <MouseWheel> events. -# -# On Windows, %D must be scaled by a factor of 120. -# -# OSX conventionally uses Shift+MouseWheel for horizontal scrolling, -# and Option+MouseWheel for accelerated scrolling. -# -# The Shift+MouseWheel behavior is not conventional on Windows or most -# X11 toolkits, but it's useful. -# # MouseWheel scrolling is accelerated on X11, which is conventional # for Tk and appears to be conventional for other toolkits (although # Gtk+ and Qt do not appear to use as large a factor). @@ -297,24 +285,8 @@ proc ttk::copyBindings {from to} { # proc ttk::bindMouseWheel {bindtag callback} { - if {[tk windowingsystem] eq "x11"} { - bind $bindtag <Button-4> "$callback -1" - bind $bindtag <Button-5> "$callback +1" - } - if {[tk windowingsystem] eq "aqua"} { - bind $bindtag <MouseWheel> [append callback { [expr {-(%D)}]} ] - bind $bindtag <Option-MouseWheel> [append callback { [expr {-10 *(%D)}]} ] - } else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/120 = 0, - # but - # (int)-1/120 = -1 - # The following code ensure equal +/- behaviour. - bind $bindtag <MouseWheel> [append callback { [ - expr {%D>=0 ? (-%D/120) : ((119-%D)/120)} - ]}] - } + bind $bindtag <MouseWheel> [append callback { %D -120.0}] + bind $bindtag <Option-MouseWheel> [append callback { %D -12.0}] } ## Mousewheel bindings for standard scrollable widgets. @@ -325,46 +297,13 @@ proc ttk::bindMouseWheel {bindtag callback} { # standard scrollbar protocol. # -if {[tk windowingsystem] eq "x11"} { - bind TtkScrollable <Button-4> { %W yview scroll -5 units } - bind TtkScrollable <Button-5> { %W yview scroll 5 units } - bind TtkScrollable <Shift-Button-4> { %W xview scroll -5 units } - bind TtkScrollable <Shift-Button-5> { %W xview scroll 5 units } -} -if {[tk windowingsystem] eq "aqua"} { - bind TtkScrollable <MouseWheel> { - %W yview scroll [expr {-(%D)}] units - } - bind TtkScrollable <Shift-MouseWheel> { - %W xview scroll [expr {-(%D)}] units - } - bind TtkScrollable <Option-MouseWheel> { - %W yview scroll [expr {-10 * (%D)}] units - } - bind TtkScrollable <Shift-Option-MouseWheel> { - %W xview scroll [expr {-10 * (%D)}] units - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/120 = 0, - # but - # (int)-1/120 = -1 - # The following code ensure equal +/- behaviour. - bind TtkScrollable <MouseWheel> { - if {%D >= 0} { - %W yview scroll [expr {-%D/120}] units - } else { - %W yview scroll [expr {(119-%D)/120}] units - } - } - bind TtkScrollable <Shift-MouseWheel> { - if {%D >= 0} { - %W xview scroll [expr {-%D/120}] units - } else { - %W xview scroll [expr {(119-%D)/120}] units - } - } -} +bind TtkScrollable <MouseWheel> \ + { tk::MouseWheel %W y %D } +bind TtkScrollable <Option-MouseWheel> \ + { tk::MouseWheel %W y %D -12.0 } +bind TtkScrollable <Shift-MouseWheel> \ + { tk::MouseWheel %W x %D } +bind TtkScrollable <Shift-Option-MouseWheel> \ + { tk::MouseWheel %W x %D -12.0 } #*EOF* |