Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: A Drag and Drop (perl/Tk) question.

by grummerX (Pilgrim)
on Jul 29, 2002 at 15:16 UTC ( [id://186007]=note: print w/replies, xml ) Need Help??


in reply to A Drag and Drop (perl/Tk) question.

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...)

Replies are listed 'Best First'.
Re: Re: A Drag and Drop (perl/Tk) question.
by hiseldl (Priest) on Jul 29, 2002 at 18:09 UTC
    grummerX is correct with his new Drop method, you need to grab X and Y from the source event in order to get the correct list item using GetNearest.

    Also, the example given at Drag-and-Drop Primer binds a mouse event, for the drag start, to all widgets that are DND capable. This approach works better for canvas to canvas image or shape dropping than list to list dropping. A better example would be Drag and drop with Perl/Tk as this covers DND from list to list.

    --
    hiseldl

Re: Re: A Drag and Drop (perl/Tk) question.
by blackadder (Hermit) on Jul 29, 2002 at 16:09 UTC
    I do not know now what’s really is going on?

    I've started with amending this line :

    my $idx = $w->GetNearst($e->x, $e->y);<br><br>
    To this (as it was suggested ) :

    my $idx = $w-><b>GetNearest</b>($e->x, $e->y);


    And I got loads of errors because of the "b" and "/b". So I am back to 1^2.

    Recently I have read an article on PM about a guy who has given up programming. It was very interesting read, and I couldn’t really see why he did this….Now I can.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://186007]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (1)
As of 2024-04-25 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found