in reply to Re: Dragging/Dropping images with Tk
in thread Dragging/Dropping images with Tk

Thanks.

But, where do I find dnd_demo (not anywhere on my sytem, CPAN, or this site, and a web search would turn up non-domain results--i.e., the game dungeons and dragons, dnd).

Also, the T::DropSite doc didn't tell me much (aside from the pod commands, the only real 'meat' was:

use Tk::DropSite qw(...); $widget->DropSite(-entercommand => ..., -dropcommand => ..., -motioncommand => ..., -dropcommand => ..., );
Which doesn't exactly tell me much on the way of what the things do -- and trying to run a simple call resulted in an error)

I don't have the latest version of Perl/Tk if that's a probelm (the only way to get it for active state is to have VC++, recommended v.6, if another way I'd be glad to know)

Replies are listed 'Best First'.
Re: Re: Re: Dragging/Dropping images with Tk
by stefp (Vicar) on Jul 06, 2002 at 19:51 UTC
    As I messaged you, you can handle tarballs with winzip. Also, you can search Tk related packages on search.cpan.org. Tk-DKW seems a good complement to raw Tk, specially TK::IconCanvas even if the documentation is... sketchy.

    I am not a windows user so I would not dare to ask you to switch from ActiveState ppm to the cpan installer. This subjet has probably be treated before...

    -- stefp -- check out TeXmacs wiki

Re: x3 Dragging/Dropping images with Tk
by stefp (Vicar) on Jul 06, 2002 at 20:22 UTC
    It is years I have not used Tk so I read some docs to refresh my memory. I would indeed implement the "table" with a Tk::Canvas and the cards with bitmaps items. You need to add handlers to move the cards. I will probably send some some code if I can get some juice from my brain cells.

    I first thought using TopLevel windows for moved cards and using Tk::wm overrideredirect to ask the window manager not to decorate the said windows/cards, But this is more complex and does probably work only on X-Window.

    -- stefp -- check out TeXmacs wiki

      I don't know if its a big deal, but the cards are Photo types (they're .gif so Bitmap wouldn't be appropriate I don't think, and as the book I got tells me, bitmap isn't what the 'Windows' world thinks of, so I couldn't just convert it using Paint Shop Pro, for example).

      Thanks though, I'll go off to re-read on TK::Canvas and "table".

        There is no such class as a table. I was just trying to name the surface you want to emulate. :) With the following code, you should have everything to start with. It says when you pick the card, moves it when you drag the mouse, and say when you drop the said card. You should read Tk::bind and Tk::callbacks to fill the details.. Pick a real gif file name as the file parameter!.
        use strict; use Tk qw( Ev ); my $m = MainWindow->new(); my $c = $m->Canvas->pack( -expand => 1, fill => 'both'); my ($lastx, $lasty) = (100, 100); my $card = $c->createImage($lastx, $lasty, -image => $m->Photo(-file => '/usr/lib/perl5/site_perl/5.6.1/i386-linux/Tk/X +camel.gif', -format => 'gif'), -anchor => 'center'); $c->bind( $card, "<1>", sub { print STDERR "bark\n"; } ); $c->bind( $card, "<B1-Motion>", [ \&mymovehandler, $card, Ev("x"),Ev(" +y"), ]); # note how the event handler is setup: as a a reference # to an array. Array elements are the handler # and its parameters. See Tk::Bind about the Ev("x") and some such. $c->bind( $card, "<ButtonRelease-1>", sub { print STDERR "dropped\n"; +} ); sub mymovehandler { my ($canvas, $card, $x, $y ) = @_;; $c->move($card, $x -$lastx, $y - $lasty); ($lastx, $lasty) = ($x, $y); } Tk::MainLoop();

        -- stefp -- check out TeXmacs wiki