From 4eef134b81ce51c72de77bbf523a61f83a4302ba Mon Sep 17 00:00:00 2001 From: jenglish Date: Tue, 27 May 2014 19:33:22 +0000 Subject: ttk::entry, ttk::combobox: proposed fix for [a80f5d7165]: keep track of whether a drag transaction is in progress; only initiate autoscroll in if selectMode is not "none" and if %m is NotifyNormal. --- library/ttk/entry.tcl | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 2c9fbc8..f16cf8b 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -14,7 +14,7 @@ namespace eval ttk { variable State set State(x) 0 - set State(selectMode) char + set State(selectMode) none set State(anchor) 0 set State(scanX) 0 set State(scanIndex) 0 @@ -74,9 +74,9 @@ bind TEntry { ttk::entry::Select %W %x word } bind TEntry { ttk::entry::Select %W %x line } bind TEntry { ttk::entry::Drag %W %x } -bind TEntry { ttk::Repeatedly ttk::entry::AutoScroll %W } -bind TEntry { ttk::CancelRepeat } -bind TEntry { ttk::CancelRepeat } +bind TEntry { ttk::entry::DragOut %W %m } +bind TEntry { ttk::entry::DragIn %W } +bind TEntry { ttk::entry::Release %W } bind TEntry { %W instate {!readonly !disabled} { %W icursor @%x ; focus %W } @@ -404,14 +404,40 @@ proc ttk::entry::DragTo {w x} { char { CharSelect $w $State(anchor) $cur } word { WordSelect $w $State(anchor) $cur } line { LineSelect $w $State(anchor) $cur } + none { # no-op } } } +## binding: +# Begin autoscroll. +# +proc ttk::entry::DragOut {w mode} { + variable State + if {$State(selectMode) ne "none" && $mode eq "NotifyNormal"} { + ttk::Repeatedly ttk::entry::AutoScroll $w + } +} + +## binding +# Suspend autoscroll. +# +proc ttk::entry::DragIn {w} { + ttk::CancelRepeat +} + +## binding +# +proc ttk::entry::Release {w} { + variable State + set State(selectMode) none + ttk::CancelRepeat ;# suspend autoscroll +} + ## AutoScroll # Called repeatedly when the mouse is outside an entry window # with Button 1 down. Scroll the window left or right, -# depending on where the mouse is, and extend the selection -# according to the current selection mode. +# depending on where the mouse left the window, and extend +# the selection according to the current selection mode. # # TODO: AutoScroll should repeat faster (50ms) than normal autorepeat. # TODO: Need a way for Repeat scripts to cancel themselves. -- cgit v0.12