[macOS] Tcl::pTk Drag&Drop

[email protected] (welle Ozean via tcltk) Fri, 21 Sep 2018 13:01:08 +0200
Newsgroups perl.tcltk
Message-ID <CAL0NCLuWHnhbs1xOA0xqp+HoP44s0aRiHx_9S4KiSUTNqBTkGQ@mail.gmail.com>
--0000000000002fa11a05765f8f35
Content-Type: text/plain; charset="UTF-8"

Using Tcl::pTk I am trying to implement Drag&Drop on macOS without success.
According to its documentation, Tcl::pTk should support it. This is what I
am trying now (slightly adapted from my version for Windows and Perl/Tk):

$MyWidget->DropSite(-dropcommand => [\&accept_drop, $tap], -droptypes =>
(['Local', 'tkdnd']));

sub accept_drop {
    my ($tab) = @_;
    my $filePath;
     eval {
if ($^O eq 'MSWin32') {
$filePath = $tab->SelectionGet(-selection => $selection,
 'STRING');
}
else {
$filePath = $tab->SelectionGet(-selection => $selection,
 'FILE_NAME');
}
      }
#DO THINGS with $filePath
}

I have downloaded a binary of tkdnd (libtkdnd2.8.dylib). How do I let
Tcl::pTk know of this library? Or there is any way to implement it without
adding new libraries (I am using the Tcl shipped with macOS).

Thanks
Welle

--0000000000002fa11a05765f8f35
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div di=
r=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Using Tcl::pTk I am trying to i=
mplement Drag&amp;Drop on macOS without success. According to its documenta=
tion, Tcl::pTk should support it. This is what I am trying now (slightly ad=
apted from my version for Windows and Perl/Tk):<div><br></div><div>$MyWidge=
t-&gt;DropSite(-dropcommand =3D&gt; [\&amp;accept_drop, $tap], -droptypes =
=3D&gt; ([&#39;Local&#39;, &#39;tkdnd&#39;]));<br></div><div><br></div><div=
><div>sub accept_drop {</div><div>=C2=A0 =C2=A0 my ($tab) =3D @_;</div><div=
>=C2=A0 =C2=A0 my $filePath;</div><div>=C2=A0 =C2=A0 =C2=A0eval {</div><div=
><span class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">		</span>if=
 ($^O eq &#39;MSWin32&#39;) {</div><div><span class=3D"gmail-Apple-tab-span=
" style=3D"white-space:pre">			</span>$filePath =3D $tab-&gt;SelectionGet(-=
selection =3D&gt; $selection,</div><div><span class=3D"gmail-Apple-tab-span=
" style=3D"white-space:pre">							</span> =C2=A0&#39;STRING&#39;);</div><d=
iv><span class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">		</span>=
}</div><div><span class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">=
		</span>else {</div><div><span class=3D"gmail-Apple-tab-span" style=3D"whi=
te-space:pre">			</span>$filePath =3D $tab-&gt;SelectionGet(-selection =3D&=
gt; $selection,</div><div><span class=3D"gmail-Apple-tab-span" style=3D"whi=
te-space:pre">							</span> =C2=A0&#39;FILE_NAME&#39;);</div><div><span cl=
ass=3D"gmail-Apple-tab-span" style=3D"white-space:pre">		</span>}</div><div=
>=C2=A0 =C2=A0 =C2=A0 }</div><div>#DO THINGS with $filePath</div><div>}</di=
v><div><br></div></div><div>I have downloaded a binary of tkdnd (libtkdnd2.=
8.dylib). How do I let Tcl::pTk know of this library? Or there is any way t=
o implement it without adding new libraries (I am using the Tcl shipped wit=
h macOS).</div><div><br></div><div>Thanks</div><div>Welle</div></div></div>=
</div></div></div></div></div>

--0000000000002fa11a05765f8f35--