summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortreectrl <treectrl>2005-07-12 03:42:33 (GMT)
committertreectrl <treectrl>2005-07-12 03:42:33 (GMT)
commitc1466e471f1b97decac394eb4a8012a1d21700e0 (patch)
tree989d8a1e781ac3b24a22995003b5ece091410691
parent6a0bb30a142ee32515f0dd7d1ca5845529aecc46 (diff)
downloadtktreectrl-c1466e471f1b97decac394eb4a8012a1d21700e0.zip
tktreectrl-c1466e471f1b97decac394eb4a8012a1d21700e0.tar.gz
tktreectrl-c1466e471f1b97decac394eb4a8012a1d21700e0.tar.bz2
Set -showbuttons to false, allow click anywhere in item to toggle it open/closed. Change cursor to hand2 to indicate toggle is allowed.
Add bindings to child windows to make Identify Window updates work.
-rw-r--r--demos/biglist.tcl47
1 files changed, 41 insertions, 6 deletions
diff --git a/demos/biglist.tcl b/demos/biglist.tcl
index 268c8d4..5dbcbbf 100644
--- a/demos/biglist.tcl
+++ b/demos/biglist.tcl
@@ -1,4 +1,4 @@
-# RCS: @(#) $Id: biglist.tcl,v 1.2 2005/07/11 01:59:07 treectrl Exp $
+# RCS: @(#) $Id: biglist.tcl,v 1.3 2005/07/12 03:42:33 treectrl Exp $
proc DemoBigList {} {
@@ -11,7 +11,7 @@ proc DemoBigList {} {
#
$T configure -selectmode extended \
- -showroot no -showbuttons yes -showlines no \
+ -showroot no -showbuttons no -showlines no \
-showrootlines no
# Hide the borders because child windows appear on top of them
@@ -101,7 +101,7 @@ proc DemoBigList {} {
set index 1
foreach I [$T item create -count 10000 -parent root -button yes -open no \
-height 20] {
- set ::BigList(titleIndex,$I) $index
+ set BigList(titleIndex,$I) $index
incr index 10
}
@@ -116,8 +116,9 @@ proc DemoBigList {} {
BigListItemVisibility %T %v %h
}
- set ::BigList(freeWindows) {}
- set ::BigList(nextWindowId) 0
+ set BigList(freeWindows) {}
+ set BigList(nextWindowId) 0
+ set BigList(prev) ""
# Create a new window just to get the requested size. This will be the
# value of the item -height option for some items.
@@ -125,7 +126,7 @@ proc DemoBigList {} {
update idletasks
set height [winfo reqheight $w]
incr height
- set ::BigList(windowHeight) $height
+ set BigList(windowHeight) $height
bind DemoBigList <Double-ButtonPress-1> {
if {[lindex [%W identify %x %y] 0] eq "header"} {
@@ -139,6 +140,15 @@ proc DemoBigList {} {
BigListButton1 %W %x %y
break
}
+ bind DemoBigList <Motion> {
+ BigListMotion %W %x %y
+ }
+
+ bind DemoBigListChildWindow <Motion> {
+ set x [expr {%X - [winfo rootx .f2.f1.t]}]
+ set y [expr {%Y - [winfo rooty .f2.f1.t]}]
+ BigListMotion .f2.f1.t $x $y
+ }
bindtags $T [list $T DemoBigList TreeCtrl [winfo toplevel $T] all]
@@ -273,6 +283,7 @@ puts "reuse window $w"
-command [list $w.mb2 configure -text $label]
}
+ # Button
button $w.b3 -text "Anal Probe Wizard..." -command [list tk_messageBox \
-parent . -message \
"After abducting and probing these people over the last\n\
@@ -284,6 +295,10 @@ puts "reuse window $w"
grid $w.label2 -row 1 -column 0 -sticky w -padx {0 8}
grid $w.mb2 -row 1 -column 1 -sticky w -pady 4
grid $w.b3 -row 3 -column 0 -columnspan 2 -sticky we -pady {0 4}
+
+ AddBindTag $w DemoBigListChildWindow
+ AddBindTag $w TagIdentify
+
puts "create window $w"
}
@@ -327,3 +342,23 @@ proc BigListButton1 {w x y} {
return
}
+proc BigListMotion {w x y} {
+ global BigList
+ set id [$w identify $x $y]
+ if {[lindex $id 0] eq "item"} {
+ set item [lindex $id 1]
+ if {[$w depth $item] < 3} {
+ if {$item ne $BigList(prev)} {
+ $w configure -cursor hand2
+ set BigList(prev) $item
+ }
+ return
+ }
+ }
+ if {$BigList(prev) ne ""} {
+ $w configure -cursor ""
+ set BigList(prev) ""
+ }
+ return
+}
+