For Programmers: Free Programming Magazines  


Home > Archive > Tcl > September 2006 > BWidget Tree double-click









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author BWidget Tree double-click
Daniel

2006-09-28, 7:02 pm

Hi,

Until now, the program shows the Tree widget with one file of my home
folder on each node (like a tree file explorer).
How can I make something happend when I double-click a node?
I didn't find information about doing this on the official
documentation.

[]'s

Leopold Gerlinger

2006-09-29, 4:08 am

Daniel wrote:
> Hi,
>
> Until now, the program shows the Tree widget with one file of my home
> folder on each node (like a tree file explorer).
> How can I make something happend when I double-click a node?
> I didn't find information about doing this on the official
> documentation.
>
> []'s
>


It is I'm sure. I'll give you a snippet out of a tree editor I've
developed in the past. Assuming the tree widget is stored in 'wTree' you
will bind the double-click to the tree:

$wTree bindText <Double-1> "nodeRename $wTree $wProc"
$wTree bindImage <Double-1> "nodeRename $wTree $wProc"

## The bind procedure is then called with the selected (double-clicked)
node appended as last parameter

proc nodeRename { tree wdata node } \
{
global lastNode currentNode currentType currentName status

## Save current edited text
if {$currentNode != ""} {

set value [$wdata get 1.0 end]
set value [string range $value 0 [expr [string length $value] - 2]]
$tree itemconfigure $currentNode -data [list $currentType
$currentName $value]
}

## Get selected item
set nData [$tree itemcget $node -data]
set nType [lindex $nData 0]

..................

Hope you find it useful.

Regards - Leo
tang@jtang.org

2006-09-29, 7:03 pm

leopold.gerlinger@siemens.com zaps a wand of polymorph at the ground.
It now reads:
> $wTree bindText <Double-1> "nodeRename $wTree $wProc"
> $wTree bindImage <Double-1> "nodeRename $wTree $wProc"


As a note, doing both a bindText and a bindImage call upon the same Tree
does not work as expected; the latter call overrides the former. (See
http://tinyurl.com/p38fs for bug report.) With the forthcoming BWidget
1.8 you may want to use bindArea instead.

--
Jason Tang / tang@jtang.org / http://www.jtang.org/~tang
Daniel

2006-09-29, 7:03 pm

It worked fine!
Thanks for helping!

[]'s

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com