Permalink
Browse files

The <Left> and <Right> arrow keys expand/collapse the current item if…

… -orient=vertical and -wrap={}.
  • Loading branch information...
1 parent 8fa563c commit df5c976aa88acc56a303411ae481f9c1c89f4f69 treectrl committed Jul 21, 2008
Showing with 11 additions and 3 deletions.
  1. +11 −3 library/treectrl.tcl
View
@@ -1,4 +1,4 @@
-# RCS: @(#) $Id: treectrl.tcl,v 1.39 2006/12/07 03:47:01 treectrl Exp $
+# RCS: @(#) $Id: treectrl.tcl,v 1.40 2008/07/21 18:36:41 treectrl Exp $
bind TreeCtrl <Motion> {
TreeCtrl::CursorCheck %W %x %y
@@ -53,7 +53,11 @@ bind TreeCtrl <Shift-KeyPress-Down> {
TreeCtrl::Extend %W below
}
bind TreeCtrl <KeyPress-Left> {
- TreeCtrl::SetActiveItem %W [TreeCtrl::LeftRight %W active -1]
+ if {[%W cget -orient] eq "vertical" && [%W cget -wrap] eq ""} {
+ %W item collapse [%W item id active]
+ } else {
+ TreeCtrl::SetActiveItem %W [TreeCtrl::LeftRight %W active -1]
+ }
}
bind TreeCtrl <Shift-KeyPress-Left> {
TreeCtrl::Extend %W left
@@ -62,7 +66,11 @@ bind TreeCtrl <Control-KeyPress-Left> {
%W xview scroll -1 pages
}
bind TreeCtrl <KeyPress-Right> {
- TreeCtrl::SetActiveItem %W [TreeCtrl::LeftRight %W active 1]
+ if {[%W cget -orient] eq "vertical" && [%W cget -wrap] eq ""} {
+ %W item expand [%W item id active]
+ } else {
+ TreeCtrl::SetActiveItem %W [TreeCtrl::LeftRight %W active 1]
+ }
}
bind TreeCtrl <Shift-KeyPress-Right> {
TreeCtrl::Extend %W right

0 comments on commit df5c976

Please sign in to comment.