diff options
author | fvogel <fvogelnew1@free.fr> | 2019-12-14 20:06:30 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2019-12-14 20:06:30 (GMT) |
commit | b5f82eb05e0aa9998385cef1a3135e5a9044c86c (patch) | |
tree | c58632dec02b230440da7eb8ca89868ecf5af901 | |
parent | efae1b799e7c55c25fcda6f682415a8fd6e2a25f (diff) | |
parent | da273a3121cac74628721669428f7df9efe373a7 (diff) | |
download | tk-b5f82eb05e0aa9998385cef1a3135e5a9044c86c.zip tk-b5f82eb05e0aa9998385cef1a3135e5a9044c86c.tar.gz tk-b5f82eb05e0aa9998385cef1a3135e5a9044c86c.tar.bz2 |
Fix [b3b56ae8dc]: ttk widgets overwrite user-set -cursor option
-rw-r--r-- | library/ttk/combobox.tcl | 4 | ||||
-rw-r--r-- | library/ttk/cursors.tcl | 26 | ||||
-rw-r--r-- | library/ttk/panedwindow.tcl | 13 | ||||
-rw-r--r-- | library/ttk/spinbox.tcl | 4 | ||||
-rw-r--r-- | library/ttk/treeview.tcl | 6 | ||||
-rw-r--r-- | tests/ttk/ttk.test | 13 |
6 files changed, 59 insertions, 7 deletions
diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl index 1355a04..2770142 100644 --- a/library/ttk/combobox.tcl +++ b/library/ttk/combobox.tcl @@ -149,12 +149,14 @@ proc ttk::combobox::Drag {w x} { # Set cursor. # proc ttk::combobox::Motion {w x y} { + variable State + ttk::saveCursor $w State(userConfCursor) [ttk::cursor text] if { [$w identify $x $y] eq "textarea" && [$w instate {!readonly !disabled}] } { ttk::setCursor $w text } else { - ttk::setCursor $w "" + ttk::setCursor $w $State(userConfCursor) } } diff --git a/library/ttk/cursors.tcl b/library/ttk/cursors.tcl index 852f01c..9125acb 100644 --- a/library/ttk/cursors.tcl +++ b/library/ttk/cursors.tcl @@ -137,8 +137,30 @@ proc ttk::cursor {name} { proc ttk::setCursor {w name} { variable Cursors - if {[$w cget -cursor] ne $Cursors($name)} { - $w configure -cursor $Cursors($name) + if {[info exists Cursors($name)]} { + set cursorname $Cursors($name) + } else { + set cursorname $name + } + if {[$w cget -cursor] ne $cursorname} { + $w configure -cursor $cursorname + } +} + +## ttk::saveCursor $w $saveVar $excludeList -- +# Set variable $saveVar to the -cursor value from widget $w, +# if either: +# a. $saveVar does not yet exist +# b. the currently user-specified cursor for $w is not in +# $excludeList + +proc ttk::saveCursor {w saveVar excludeList} { + upvar $saveVar sv + if {![info exists sv]} { + set sv [$w cget -cursor] + } + if {[$w cget -cursor] ni $excludeList} { + set sv [$w cget -cursor] } } diff --git a/library/ttk/panedwindow.tcl b/library/ttk/panedwindow.tcl index a2e073b..ba47003 100644 --- a/library/ttk/panedwindow.tcl +++ b/library/ttk/panedwindow.tcl @@ -62,13 +62,22 @@ proc ttk::panedwindow::Release {w x y} { # proc ttk::panedwindow::ResetCursor {w} { variable State + + ttk::saveCursor $w State(userConfCursor) \ + [list [ttk::cursor hresize] [ttk::cursor vresize]] + if {!$State(pressed)} { - ttk::setCursor $w {} + ttk::setCursor $w $State(userConfCursor) } } proc ttk::panedwindow::SetCursor {w x y} { - set cursor "" + variable State + + ttk::saveCursor $w State(userConfCursor) \ + [list [ttk::cursor hresize] [ttk::cursor vresize]] + + set cursor $State(userConfCursor) if {[llength [$w identify $x $y]]} { # Assume we're over a sash. switch -- [$w cget -orient] { diff --git a/library/ttk/spinbox.tcl b/library/ttk/spinbox.tcl index 90a1572..9728755 100644 --- a/library/ttk/spinbox.tcl +++ b/library/ttk/spinbox.tcl @@ -29,12 +29,14 @@ ttk::bindMouseWheel TSpinbox [list ttk::spinbox::MouseWheel %W] # Sets cursor. # proc ttk::spinbox::Motion {w x y} { + variable State + ttk::saveCursor $w State(userConfCursor) [ttk::cursor text] if { [$w identify $x $y] eq "textarea" && [$w instate {!readonly !disabled}] } { ttk::setCursor $w text } else { - ttk::setCursor $w "" + ttk::setCursor $w $State(userConfCursor) } } diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl index 8cd3e75..99210af 100644 --- a/library/ttk/treeview.tcl +++ b/library/ttk/treeview.tcl @@ -102,7 +102,11 @@ proc ttk::treeview::Keynav {w dir} { # Sets cursor, active element ... # proc ttk::treeview::Motion {w x y} { - set cursor {} + variable State + + ttk::saveCursor $w State(userConfCursor) [ttk::cursor hresize] + + set cursor $State(userConfCursor) set activeHeading {} switch -- [$w identify region $x $y] { diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index 9f78966..9fb4c30 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -507,6 +507,19 @@ test ttk-12.2 "-cursor option" -body { .b cget -cursor } -result arrow +test ttk-12.2.1 "-cursor option, widget doesn't overwrite it" -setup { + ttk::treeview .tr + pack .tr + update +} -body { + .tr configure -cursor X_cursor + event generate .tr <Motion> + update + .tr cget -cursor +} -cleanup { + destroy .tr +} -result {X_cursor} + test ttk-12.3 "-borderwidth frame option" -body { destroy .t toplevel .t |