Should read:my $idx = $w->GetNearst($e->x, $e->y);
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:
O'Reilly has a good Drag-and-Drop Primer available; you should check it out.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); } }
-- grummerX
Update: Removed HTML tags in code. (stupid, stupid...)In reply to Re: A Drag and Drop (perl/Tk) question.
by grummerX
in thread A Drag and Drop (perl/Tk) question.
by blackadder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |