Tk Library Source Code

View Ticket
Login
Ticket UUID: 1042613
Title: Can't drag into an emtpy tree widget
Type: Bug Version: None
Submitter: pointsman Created on: 2004-10-07 22:16:12
Subsystem: bwidget Assigned To: damonc
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-06-30 22:18:05
Resolution: Fixed Closed By: oehhar
    Closed on: 2009-06-30 15:18:05
Description:
A drag to a tree widget does not work, if the
destination tree doesn't have any nodes. 

This script illustrates the problem:

package require BWidget

proc dropcmd {dest source dropInfo operation dataType
data} {
    set sourceTree [winfo parent $source]
    $dest insert end root $data \
         -text [$sourceTree itemcget $data -text]
    $sourceTree delete $data
} 

set t1 [Tree .t1 -dragenabled 1]
$t1 insert end root aNode -text "A sample Node"

set t2 [Tree .t2 -dropenabled 1 \
            -dropovermode w \
            -dropcmd dropcmd]
# If the destination tree has at least one node,
everything works
# $t2 insert end root anotherNode  -text "Another node"

pack $t1 $t2 -side left

If the destination tree doesn't have a node, the
dropcmd will not be called. As far, as I've debugged
the problem, the reason, that the dropcmd isn't called,
is in  Tree::_drop_cmd:
    if {[llength $data(dnd,node)]
        && [llength [set cmd [Widget::getoption $path
-dropcmd]]]} {
        return [uplevel \#0 $cmd \
                    [list $path $source $data(dnd,node)
$op $type $dnddata]]
    }
If the destination tree doesn't have a node,
$data(dnd,node) is empty (but should be "widget", as
far, as I can tell)
User Comments: oehhar added on 2009-06-30 22:18:04:
Confirmed.
I removed the condition about existing nodes in Tree_drop_cmd and it worked.
So we call this a patch and commit it to cvs.