Hi Dave, > I'm not sure if tkdnd is in Perl, v5.8.8, binary build 822. > If it isn't > then I can't use it. I'm writing these scripts at work and everyone > needs to have the same version of Perl so that scripts that > run on my PC > also run on someone else's. And in the past the managers > were reluctant > to upgrade the version of Perl.
I think that "tkdnd" is not packaged with Activeperl distribution 5.8.8, and also I very much doubt that it is distributed with other newer packages. Jan Dubious and/or Jeff Hobbs have much better understanding on this packaging than I, so maybe they comment? > I tried adding > "Tkx::package_require('tkdnd');" and got an error, which is > what made me > think it might not be in this version. that's not the version, but rather packaging. OTOH taking "tkdnd" with your scripts is simplier than you think. Same magnitude of complexity compared to distributing your application. > > If tkdnd is not available, then I guess I'm stuck trying to > use Bwidget. > I saw a quote, which I think is yours, on an older post that says: > "BWidgets is well-documented, so if you need inter-app DND, > then it will > suffice." But, you think that Bwidget DND will not allow DND with > external apps? BWidgets is well-supported, but IMHO harder to use. It is better WRT cross-platform, I guess, but lacks some features. "tkdnd" does suffice me on both Linux and Windoz, and indeed it was not updated for a long time already.... (maybe this is a good sign - no need to update :) ) > > I made the suggested change and there was no change. I thought that all array references automatically converted to Tcl lists, but obviously it was not the case. What you really need - is Tkx::list function. It is not documented, but you can "derive" it from following fragment of "perldoc Tkx": <q> Tkx::*foo*( @args ) Any other function will invoke the *foo* Tcl function with the given arguments. The name *foo* first undergo the following substitutions of embedded underlines: foo_bar --> "foo", "bar" # break into words foo__bar --> "foo::bar" # access namespaces foo___bar --> "foo_bar" # when you actually need a '_' This allow us conveniently to map most of the Tcl namespace to Perl. If this mapping does not suit you, use "Tkx::i::call($func, @args)". This will invoke the function named by $func with no name substitutions or magic. </q> This function, and also Tkx::eval, and probably some other, deserve some special mention and examples. After even more reading of "http://wiki.tcl.tk/16126" and given this speculation, here is the working code snippet <code> use strict; use warnings; use Tkx; my $text = "abc"; Main(@ARGV); exit(0); sub Main { local $Tkx::TRACE = 64; Tkx::package_require('tile'); Tkx::package_require('BWidget'); eval { Tkx::tile__setTheme('xpnative'); 1 } || eval { Tkx::ttk__setTheme('xpnative'); 1 }; drawGUI(); Tkx::MainLoop(); } sub drawGUI { our $t = Tkx::widget->new("."); $t->g_wm_title("BWidgets Demo for Drag 'n Drop enabled buttons."); $t = $t->new_ttk__frame( -name => '.f' ); $t->g_pack(qw '-fill both -expand true'); for my $i ( 1 .. 4 ) { my $m = (qw' 0 Drag and Drop Demo ')[$i]; my $bb = $t->new_ttk__button(-name => "$t.b$i", # auto-name is .b .b2 .b3... -image => Tkx::Bitmap__get( (qw'0 new file copy redo ')[$i] ), -text => "$i.) $m", -command => sub { print "$m\n"; }); $bb->g_pack; } enableDnD( map { "$t.b$_" } 1 .. 4 ); $t->new_ttk__button(-text => "Exit Demo", -command => [ \&Tkx::destroy, '.' ])->g_pack(qw'-padx 5 -pady 5'); my $entry = $t->new_entry(-width => 20, -textvariable => \$text); Tkx::DropSite__register($entry, -dropcmd => \&dropcmdEntry, -dropovercmd => \&dropovercmdEntry, -droptypes => Tkx::list("FOO_BAR_FLUFFY_TYPE", Tkx::list('copy', '', 'move', '', 'link', '')), ); $entry->g_pack(qw '-padx 5 -pady 5'); } sub enableDnD { Tkx::DragSite__include('entry', 'FOO_BAR_FLUFFY_TYPE', '<B1-Motion>'); for my $w (@_) { Tkx::DropSite__register($w, -dropcmd => \&dropButtonCmd, -droptypes => Tkx::list("FOO_BAR_FLUFFY_TYPE", Tkx::list('copy', '', 'move', '', 'link', '')), ); Tkx::DragSite__register($w, -dragevent => 1, -draginitcmd => \&dragInitCmd, -dragendcmd => \&dragEndCmd ); } } sub dropButtonCmd { my @args = (@_); print "in dropButtonCmd\n"; for (my $i = 0; $i < scalar @args; $i++) { print "arg $i = '$args[$i]'\n" if defined $args[$i]; } return Tkx::list("FOO_BAR_FLUFFY_TYPE", "copy", "qwerty"); } sub dragInitCmd { my @args = (@_); print "in dragInitCmd\n"; for (my $i = 0; $i < scalar @args; $i++) { print "arg $i = '$args[$i]'\n" if defined $args[$i]; } my $data = "\"Button " . $args[3] . "\""; return Tkx::list('FOO_BAR_FLUFFY_TYPE', "copy", $data ); } sub dragEndCmd { my @args = (@_); print "in dragEndCmd\n"; for (my $i = 0; $i < scalar @args; $i++) { print "arg $i = '$args[$i]'\n" if defined $args[$i]; } } sub dropcmdEntry { print "dropcmdEntry\n"; return "entry"; } sub dropovercmdEntry { print "dropovercmdEntry\n"; } </code> Best regards, Vadim.