Re: [macOS] Tcl::pTk Drag&Drop

[email protected] (Christopher Chavez) Sat, 2 Feb 2019 01:07:25 -0600
Newsgroups perl.tcltk
Message-ID <[email protected]>
--Apple-Mail=_DD0D3CF1-B223-4F82-A6E6-B130388B48AD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

(Trying to send this to the list again for reference and to see if I can =
send emails now. It didn=E2=80=99t go through the first time because GMX =
had been blocked by perl.org <http://perl.org/>)

> On Sep 21, 2018, at 6:01 AM, welle Ozean via tcltk <[email protected] =
<mailto:[email protected]>> wrote:
>=20
> 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):
>=20
> $MyWidget->DropSite(-dropcommand =3D> [\&accept_drop, $tap], =
-droptypes =3D> (['Local', 'tkdnd']));
>=20
> sub accept_drop {
>     my ($tab) =3D @_;
>     my $filePath;
>      eval {
> 		if ($^O eq 'MSWin32') {
> 			$filePath =3D $tab->SelectionGet(-selection =3D> =
$selection,
> 							  'STRING');
> 		}
> 		else {
> 			$filePath =3D $tab->SelectionGet(-selection =3D> =
$selection,
> 							  'FILE_NAME');
> 		}
>       }
> #DO THINGS with $filePath
> }
>=20
> 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).
>=20
> Thanks
> Welle

Hi Welle,

As Vadim stated, neither Tcl::pTk nor Tcl.pm do much to be aware of =
Tcl/Tk modules; Tcl::pTk currently only looks for a few that are =
required (Tklib, Tix, TkTable) or have Perl-wrapper syntax for =
(BLTNotebook). Ideally, tkdnd should be installed where `package =
require` is all that=E2=80=99s needed to use it; I don=E2=80=99t know my =
way around the other `package ifneeded` or other commands that might be =
needed if Tcl/Tk needs to manually be told where it is. There is at =
least one undocumented subroutine in Tcl::pTk that might be useful, =
`$MW->interp->pkg_require()`, however I do not know what its advantages =
or limitations are over just using `$MW->interp->Eval("package require =
tkdnd=E2=80=9D)`. Though this step might be done automatically by =
Tcl::pTk depending on the syntax used.

Someone recently added tkdnd to MacPorts, so I might give it a try soon. =
I wonder if tkdnd support might be something to include in Tcl::pTk, =
similar to what=E2=80=99s done for TkTable and other Tk extensions.

Also, be aware that there have been some recent changes since tkdnd 2.8 =
was released which address issues on macOS; =
https://github.com/petasis/tkdnd/commits/master =
<https://github.com/petasis/tkdnd/commits/master>

Christopher A. Chavez=

--Apple-Mail=_DD0D3CF1-B223-4F82-A6E6-B130388B48AD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><meta=
 http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8" =
class=3D""><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: =
space; line-break: after-white-space;" class=3D""><meta =
http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8" =
class=3D""><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: =
space; line-break: after-white-space;" class=3D""><div dir=3D"auto" =
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; line-break: =
after-white-space;" class=3D"">(Trying to send this to the list again =
for reference and to see if I can send emails now. It didn=E2=80=99t go =
through the first time because GMX had been blocked by <a =
href=3D"http://perl.org/" class=3D"">perl.org</a>)<br class=3D""><div =
class=3D""><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"">On Sep 21, 2018, at 6:01 AM, welle Ozean via tcltk &lt;<a =
href=3D"mailto:[email protected]" class=3D"">[email protected]</a>&gt; =
wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div =
dir=3D"ltr" class=3D""><div dir=3D"ltr" class=3D""><div dir=3D"ltr" =
class=3D""><div dir=3D"ltr" class=3D""><div dir=3D"ltr" class=3D""><div =
dir=3D"ltr" class=3D""><div dir=3D"ltr" class=3D"">Using Tcl::pTk I am =
trying to implement Drag&amp;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):<div =
class=3D""><br class=3D""></div><div =
class=3D"">$MyWidget-&gt;DropSite(-dropcommand =3D&gt; =
[\&amp;accept_drop, $tap], -droptypes =3D&gt; (['Local', 'tkdnd']));<br =
class=3D""></div><div class=3D""><br class=3D""></div><div class=3D""><div=
 class=3D"">sub accept_drop {</div><div class=3D"">&nbsp; &nbsp; my =
($tab) =3D @_;</div><div class=3D"">&nbsp; &nbsp; my =
$filePath;</div><div class=3D"">&nbsp; &nbsp; &nbsp;eval {</div><div =
class=3D""><span class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">=
		</span>if ($^O eq 'MSWin32') {</div><div class=3D""><span =
class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">			=
</span>$filePath =3D $tab-&gt;SelectionGet(-selection =3D&gt; =
$selection,</div><div class=3D""><span class=3D"gmail-Apple-tab-span" =
style=3D"white-space:pre">							=
</span> &nbsp;'STRING');</div><div class=3D""><span =
class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">		=
</span>}</div><div class=3D""><span class=3D"gmail-Apple-tab-span" =
style=3D"white-space:pre">		</span>else {</div><div =
class=3D""><span class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">=
			</span>$filePath =3D =
$tab-&gt;SelectionGet(-selection =3D&gt; $selection,</div><div =
class=3D""><span class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">=
							</span> =
&nbsp;'FILE_NAME');</div><div class=3D""><span =
class=3D"gmail-Apple-tab-span" style=3D"white-space:pre">		=
</span>}</div><div class=3D"">&nbsp; &nbsp; &nbsp; }</div><div =
class=3D"">#DO THINGS with $filePath</div><div class=3D"">}</div><div =
class=3D""><br class=3D""></div></div><div class=3D"">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).</div><div =
class=3D""><br class=3D""></div><div class=3D"">Thanks</div><div =
class=3D"">Welle</div></div></div></div></div></div></div></div>
</div></blockquote></div><br class=3D""><div class=3D"">Hi =
Welle,</div><div class=3D""><br class=3D""></div><div class=3D"">As =
Vadim stated, neither Tcl::pTk nor Tcl.pm do much to be aware of Tcl/Tk =
modules; Tcl::pTk currently only looks for a few that are required =
(Tklib, Tix, TkTable) or have Perl-wrapper syntax for (BLTNotebook). =
Ideally, tkdnd should be installed where `package require` is all =
that=E2=80=99s needed to use it; I don=E2=80=99t know my way around the =
other `package ifneeded` or other commands that might be needed if =
Tcl/Tk needs to manually be told where it is. There is at least one =
undocumented subroutine in Tcl::pTk that might be useful, =
`$MW-&gt;interp-&gt;pkg_require()`, however I do not know what its =
advantages or limitations are over just using =
`$MW-&gt;interp-&gt;Eval("package require tkdnd=E2=80=9D)`. Though this =
step might be done automatically by Tcl::pTk depending on the syntax =
used.</div><div class=3D""><br class=3D""></div><div class=3D"">Someone =
recently added tkdnd to MacPorts, so I might give it a try soon. I =
wonder if tkdnd support might be something to include in Tcl::pTk, =
similar to what=E2=80=99s done for TkTable and other Tk =
extensions.</div><div class=3D""><br class=3D""></div><div =
class=3D"">Also, be aware that there have been some recent changes since =
tkdnd 2.8 was released which address issues on macOS; <a =
href=3D"https://github.com/petasis/tkdnd/commits/master" =
class=3D"">https://github.com/petasis/tkdnd/commits/master</a></div><div =
class=3D""><br class=3D""></div><div class=3D"">Christopher A. =
Chavez</div></div></div></div></body></html>=

--Apple-Mail=_DD0D3CF1-B223-4F82-A6E6-B130388B48AD--