summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2019-12-14 20:05:54 (GMT)
committerfvogel <fvogelnew1@free.fr>2019-12-14 20:05:54 (GMT)
commitda273a3121cac74628721669428f7df9efe373a7 (patch)
tree7fc31ed9cf8b1d4e72a0e902888b12dcf1080d2d
parent0c3533436365a18e275516bcf295e3bb0afd8149 (diff)
parent5b8024c00ad7e34076fe6cfa5facb94dfebb6bcb (diff)
downloadtk-da273a3121cac74628721669428f7df9efe373a7.zip
tk-da273a3121cac74628721669428f7df9efe373a7.tar.gz
tk-da273a3121cac74628721669428f7df9efe373a7.tar.bz2
Fix [b3b56ae8dc]: ttk widgets overwrite user-set -cursor option
-rw-r--r--library/ttk/combobox.tcl4
-rw-r--r--library/ttk/cursors.tcl26
-rw-r--r--library/ttk/panedwindow.tcl13
-rw-r--r--library/ttk/spinbox.tcl4
-rw-r--r--library/ttk/treeview.tcl6
-rw-r--r--tests/ttk/ttk.test13
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 75f7791..f1f9fa1 100644
--- a/library/ttk/cursors.tcl
+++ b/library/ttk/cursors.tcl
@@ -140,8 +140,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 df188b7..81ba27e 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 ed1c31c..aba3eba 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