G
~greg
I have reduced the following script,
but it's runnable. It's a way
to make a Tk listbox that accepts
a selection of files or folders
from Windows Explorer.
The drop handler (my "OnSourceDrop")
is apparently called individually
on each file or folder in a multiple selection.
And my question is,
is there any way to know when to call
a group-drop-handler,
to be called after all the individual
calls to OnSourceDrop() are finished
after a group drop?
thank you,
~greg
~~~~~~~~~~~~~~~~~~~~~~
use strict;
use warnings;
$|=1;
use Tk;
use Tk:
ropSite qw(Win32);
my $Main = MainWindow->new
(
-title=>'DND'
);
my %SourceList;
my $SourceListBox = $Main->Scrolled
(
"Listbox",
-scrollbars => "osoe",
)->pack
(
-fill => 'x',
);
$SourceListBox->DropSite
(
-dropcommand => [\&OnSourceDrop,$SourceListBox],
-droptypes => 'Win32',
);
sub SourceAdd
{
my $f = shift; # file or folder
return if exists $SourceList{$f};
return if ! -e $f;
$SourceList{$f} = 1;
my $slash = -d $f ? '\\' : '';
$SourceListBox->insert('end', "$f$slash" );
$SourceListBox->yviewMoveto(1);
}
sub OnSourceDrop
{
my($widget, $selection) = @_;
my $f = $widget->SelectionGet('-selection'=>$selection,'STRING');
return if ! defined $f; # is this really necessary?
SourceAdd($f);
}
MainLoop;
but it's runnable. It's a way
to make a Tk listbox that accepts
a selection of files or folders
from Windows Explorer.
The drop handler (my "OnSourceDrop")
is apparently called individually
on each file or folder in a multiple selection.
And my question is,
is there any way to know when to call
a group-drop-handler,
to be called after all the individual
calls to OnSourceDrop() are finished
after a group drop?
thank you,
~greg
~~~~~~~~~~~~~~~~~~~~~~
use strict;
use warnings;
$|=1;
use Tk;
use Tk:
my $Main = MainWindow->new
(
-title=>'DND'
);
my %SourceList;
my $SourceListBox = $Main->Scrolled
(
"Listbox",
-scrollbars => "osoe",
)->pack
(
-fill => 'x',
);
$SourceListBox->DropSite
(
-dropcommand => [\&OnSourceDrop,$SourceListBox],
-droptypes => 'Win32',
);
sub SourceAdd
{
my $f = shift; # file or folder
return if exists $SourceList{$f};
return if ! -e $f;
$SourceList{$f} = 1;
my $slash = -d $f ? '\\' : '';
$SourceListBox->insert('end', "$f$slash" );
$SourceListBox->yviewMoveto(1);
}
sub OnSourceDrop
{
my($widget, $selection) = @_;
my $f = $widget->SelectionGet('-selection'=>$selection,'STRING');
return if ! defined $f; # is this really necessary?
SourceAdd($f);
}
MainLoop;