Joshua Garrett wrote:

Hi,

I've created a PAR PP executable for OS X and Windows, and notice a
substantial difference. On Windows, the executable supports drag and drop,
with any dropped files/directories passed to ARGV. On the Mac, the
executable does not support drag and drop.

Is there a way to make drag and drop work on an OS X PAR executable, without
resorting to Dropscript or Platypus?

I need a standalone executable with drag and drop.

Thanks,

joshua







This is not a shot in the dark.  It may be a shot in the shadows.

I was believing the same thing for Linux. D&D worked fine on Windows, and D&D worked on Linux with the old Perl/Tk. However, with the newest version of Perl/Tk, Tk-804.027 11 Apr 2004 - Nick Ing-Simmons, D&D only worked on Windows. I had faithfully followed the examples, and did not change anything in my code. I did not really care so I did not report it. Then one day my eye caught something in the "sub accept_drop" from some drag and drop web examples where I originally got the code..

See "FILE_NAME" below? I changed it to "STRING" as you see because that is what the Windows section of sub accept_drop had.
------------- paste
$string_dropped = $widget->SelectionGet(-selection => $selection,
# 'FILE_NAME');
'STRING');
------------- end paste
From the on, Drag and Drop worked fine for the new Tk, too.


To save some others some work, I am pasting a file called "test_drag_and_drop.pl that works on Windows and Linux. First though, let me state that I know this may not have anything to do with why it does not work on a Mac, except perhaps if you used the same original example code I did. In any case, please let us know if this works on your Mac machine.

Thanks
-------------------------- paste test_drag_and_drop.pl
#!/usr/bin/perl -w
# file: test_drag_and_drop.pl
#################
use Tk;
use Tk::DropSite;

#################
use strict;
#################
use vars qw($mw $textbox);
#################

#################
sub accept_drop {
   my($widget, $selection) = @_;

   my $string_dropped;
   eval {
   if ($^O eq 'MSWin32') {
       $string_dropped = $widget->SelectionGet(-selection => $selection,
                         'STRING');
   } else {
       $string_dropped = $widget->SelectionGet(-selection => $selection,
#                          'FILE_NAME');
                         'STRING');
   }
   };
   if (defined $string_dropped) {
   $widget->insert('end', $string_dropped . "\n");
   }
}

#################
sub print_string_and_exit {
 my ($mw, $textbox, ) = @_;

 my $string;
 $string = $textbox->get("0.0", "end");

 print STDOUT "You dragged and dropped ::\n$string\n";

 $mw->destroy;

}

#################

$mw = new MainWindow;
$mw->title("Try to Drag and Drop");

$textbox =
     $mw->Scrolled('Text', -scrollbars => "osoe",
                           -height => 10,
                           -width => 72,
             )->pack;


$textbox->DropSite (-dropcommand => [\&accept_drop, $textbox], -droptypes => ($^O eq 'MSWin32' ? 'Win32' : ['XDND', 'Sun']) );


my $okay_button = $mw->Button( -text => "Okay", -command => [ \&print_string_and_exit, $mw, $textbox, ] )->pack( -side => 'left', -anchor => 'n', -ipadx => 10, -expand => 1, );

#.....................................................................

#########
MainLoop;
#########









Reply via email to