summaryrefslogtreecommitdiffstats
path: root/library/demos/mclist.tcl
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-08-09 07:25:45 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-08-09 07:25:45 (GMT)
commit6a53e1bcab0c83c50e6a686c0ac485687ff29b8f (patch)
tree7aaeea00884af116c6e428fd60398506e2327f51 /library/demos/mclist.tcl
parent3938a19b4a11bdae6dd2549706c83f8cac1e8b94 (diff)
downloadtk-6a53e1bcab0c83c50e6a686c0ac485687ff29b8f.zip
tk-6a53e1bcab0c83c50e6a686c0ac485687ff29b8f.tar.gz
tk-6a53e1bcab0c83c50e6a686c0ac485687ff29b8f.tar.bz2
partly backport from 8.6
Diffstat (limited to 'library/demos/mclist.tcl')
-rw-r--r--library/demos/mclist.tcl17
1 files changed, 16 insertions, 1 deletions
diff --git a/library/demos/mclist.tcl b/library/demos/mclist.tcl
index d1d3f47..21dcf29 100644
--- a/library/demos/mclist.tcl
+++ b/library/demos/mclist.tcl
@@ -77,6 +77,16 @@ foreach {country capital currency} $data {
## Code to do the sorting of the tree contents when clicked on
proc SortBy {tree col direction} {
+ # Determine currently sorted column and its sort direction
+ foreach c {country capital currency} {
+ set s [$tree heading $c state]
+ if {("selected" in $s || "alternate" in $s) && $col ne $c} {
+ # Sorted column has changed
+ $tree heading $c state {!selected !alternate !user1}
+ set direction [expr {"alternate" in $s}]
+ }
+ }
+
# Build something we can sort
set data {}
foreach row [$tree children {}] {
@@ -92,5 +102,10 @@ proc SortBy {tree col direction} {
}
# Switch the heading so that it will sort in the opposite direction
- $tree heading $col -command [list SortBy $tree $col [expr {!$direction}]]
+ $tree heading $col -command [list SortBy $tree $col [expr {!$direction}]] \
+ state [expr {$direction?"!selected alternate":"selected !alternate"}]
+ if {[tk windowingsystem] eq "aqua"} {
+ # Aqua theme displays native sort arrows when user1 state is set
+ $tree heading $col state "user1"
+ }
}