#!/usr/bin/perl use Tk; use Tk::DragDrop; use Tk::DropSite; use strict; my $var; my $curindex; my $mw=tkinit; my $listframe = $mw->Scrolled( 'Listbox', -selectmode=>'multiple', -scrollbars=>'oe')->pack; my $listbox = $listframe->Subwidget('scrolled'); $mw->Label(-text=>'Yellow Entry is the DropSite')->pack; my $entry = $mw->Entry(-bg=>'yellow')->pack; $listframe->insert('end',('A'..'Z')); my $token = $listbox->DragDrop( -event => '', -sitetypes => [qw/Local/], -startcommand=>\&draghandler, ); $entry->DropSite( -droptypes => [qw/Local/], -dropcommand => [\&fillEntry,$entry,$listbox], ); $listbox->bind('',sub { my $e=$listbox->XEvent; $curindex=$listbox->nearest($e->y); }); MainLoop; sub draghandler { #Force selection of the index under the mouse $listbox->selectionSet($curindex,$curindex); } sub fillEntry { my ($e,$l)=@_; $var=''; $e->delete(0,'end'); foreach ($l->curselection){ $var=$var.$l->get($_); } $e->insert('end',$var); $l->selectionClear(0,'end'); } __END__