In your
DragStart function, the following line:
my $idx = $w->GetNearst($e->x, $e->y);
Should read:
my $idx = $w->GetNearest($e->x, $e->y);
Your Drop function needs some changes as well. Instead of grabbing the x and y values through the properties of the directory tree, you should use the values that the Drop event sends through:
sub Drop{
my ($lb, $dnd_source, $c_dest, $sel, $dest_x, $dest_y) = @_;
my $group_item = $dnd_source->cget('-text');
my $nearest = $lb->GetNearest($dest_x, $dest_y);
if (defined $nearest){
my $dir_item = $lb->entrycget($nearest, '-text');
print "*** $dir_item ***\n"; ### DEBUG: Show target value
&AddGroupToDir($group_item, $dir_item);
$lb->see($nearest);
}
}
O'Reilly has a good
Drag-and-Drop Primer available; you should check it out.
-- grummerX
Update: Removed HTML tags in code. (stupid, stupid...)