Re: [macOS] Tcl::pTk Drag&Drop
[email protected] (welle ozean via tcltk) Sun, 2 Jun 2019 17:17:35 +0200
| Newsgroups | perl.tcltk |
|---|---|
| Message-ID | <CAL0NCLumi3wJMVUg1gRgfD=YSLDO5ufRymBKVfHvux0PiTgVsg@mail.gmail.com> |
--000000000000f57a66058a58bfa1
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Short follow up for Drag&Drop with Tcl::pTk
The easiest way to add Drag&Drop to a Tcl::pTk application has been for me
using Tcl syntax, i.e.:
use Tcl::pTk;
my $int =3D new Tcl::pTk;
$int->Eval('package require tkdnd');#loading installed version of tkdnd
$int->Eval(<<'EOS');
text .drop_target
pack .drop_target
tkdnd::drop_target register .drop_target *
bind .drop_target <<Drop>> {.drop_target insert end %D}
EOS
$int->MainLoop;
Welle
Am Sa., 2. Feb. 2019 um 08:07 Uhr schrieb Christopher Chavez <
[email protected]>:
> (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)
>
> On Sep 21, 2018, at 6:01 AM, welle Ozean via tcltk <[email protected]> wrote=
:
>
> 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 =3D> [\&accept_drop, $tap], -droptypes =
=3D>
> (['Local', 'tkdnd']));
>
> 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
> }
>
> 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 withou=
t
> adding new libraries (I am using the Tcl shipped with macOS).
>
> Thanks
> Welle
>
>
> Hi Welle,
>
> As Vadim stated, neither Tcl::pTk nor Tcl.pm do much to be aware of Tcl/T=
k
> modules; Tcl::pTk currently only looks for a few that are required (Tklib=
,
> Tix, TkTable) or have Perl-wrapper syntax for (BLTNotebook). Ideally, tkd=
nd
> 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. The=
re
> 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 o=
r
> limitations are over just using `$MW->interp->Eval("package require
> tkdnd=E2=80=9D)`. Though this step might be done automatically by Tcl::pT=
k
> 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, simila=
r
> 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
>
> Christopher A. Chavez
>
--000000000000f57a66058a58bfa1
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr">Short follow up for Drag&Drop with Tc=
l::pTk<div><br></div><div>The easiest way to add Drag&Drop to a Tcl::pT=
k application has been for me using Tcl syntax, i.e.:</div><div><br></div><=
div><div>use Tcl::pTk;</div><div>my $int =3D new Tcl::pTk;</div><div><br></=
div><div>$int->Eval('package require tkdnd');#loading installed =
version of tkdnd</div><div><br></div><div>$int->Eval(<<'EOS=
9;);</div><div>text .drop_target=C2=A0</div><div>pack .drop_target</div><di=
v>tkdnd::drop_target register .drop_target *</div><div>bind .drop_target &l=
t;<Drop>> {.drop_target insert end %D}</div><div>EOS</div><div><br=
></div><div>$int->MainLoop;</div></div><div><br></div><div>Welle</div></=
div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_at=
tr">Am Sa., 2. Feb. 2019 um 08:07=C2=A0Uhr schrieb Christopher Chavez <<=
a href=3D"mailto:[email protected]">[email protected]</a>>:<br></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l=
eft-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);pa=
dding-left:1ex"><div style=3D"word-wrap:break-word;line-break:after-white-s=
pace"><div style=3D"word-wrap:break-word;line-break:after-white-space"><div=
style=3D"word-wrap:break-word;line-break:after-white-space"><div dir=3D"au=
to" style=3D"word-wrap:break-word;line-break:after-white-space">(Trying to =
send this to the list again for reference and to see if I can send emails n=
ow. It didn=E2=80=99t go through the first time because GMX had been blocke=
d by <a href=3D"http://perl.org/" target=3D"_blank">perl.org</a>)<br><div><=
br><blockquote type=3D"cite"><div>On Sep 21, 2018, at 6:01 AM, welle Ozean =
via tcltk <<a href=3D"mailto:[email protected]" target=3D"_blank">tcltk@per=
l.org</a>> wrote:</div><br class=3D"gmail-m_-8154725089861108402Apple-in=
terchange-newline"><div><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">=
<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Using T=
cl::pTk I am trying to implement Drag&Drop on macOS without success. Ac=
cording 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=
><br></div><div>$MyWidget->DropSite(-dropcommand =3D> [\&accept_d=
rop, $tap], -droptypes =3D> (['Local', 'tkdnd']));<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-m_-8154725089861108402gmail-Ap=
ple-tab-span" style=3D"white-space:pre-wrap"> </span>if ($^O eq 'MSWin=
32') {</div><div><span class=3D"gmail-m_-8154725089861108402gmail-Apple=
-tab-span" style=3D"white-space:pre-wrap"> </span>$filePath =3D $tab->=
SelectionGet(-selection =3D> $selection,</div><div><span class=3D"gmail-=
m_-8154725089861108402gmail-Apple-tab-span" style=3D"white-space:pre-wrap">=
</span> =C2=A0'STRING');</div><div><span class=3D"gmail-m_-8=
154725089861108402gmail-Apple-tab-span" style=3D"white-space:pre-wrap"> </=
span>}</div><div><span class=3D"gmail-m_-8154725089861108402gmail-Apple-tab=
-span" style=3D"white-space:pre-wrap"> </span>else {</div><div><span class=
=3D"gmail-m_-8154725089861108402gmail-Apple-tab-span" style=3D"white-space:=
pre-wrap"> </span>$filePath =3D $tab->SelectionGet(-selection =3D> =
$selection,</div><div><span class=3D"gmail-m_-8154725089861108402gmail-Appl=
e-tab-span" style=3D"white-space:pre-wrap"> </span> =C2=A0'FILE_N=
AME');</div><div><span class=3D"gmail-m_-8154725089861108402gmail-Apple=
-tab-span" style=3D"white-space:pre-wrap"> </span>}</div><div>=C2=A0 =C2=
=A0 =C2=A0 }</div><div>#DO THINGS with $filePath</div><div>}</div><div><br>=
</div></div><div>I have downloaded a binary of tkdnd (libtkdnd2.8.dylib). H=
ow 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><br></div><div>Thanks</div><div>Welle</div></div></div></div></div=
></div></div></div>
</div></blockquote></div><br><div>Hi Welle,</div><div><br></div><div>As Vad=
im stated, neither Tcl::pTk nor Tcl.pm do much to be aware of Tcl/Tk module=
s; Tcl::pTk currently only looks for a few that are required (Tklib, Tix, T=
kTable) or have Perl-wrapper syntax for (BLTNotebook). Ideally, tkdnd shoul=
d 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 othe=
r commands that might be needed if Tcl/Tk needs to manually be told where i=
t 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 i=
ts advantages or limitations are over just using `$MW->interp->Eval(&=
quot;package require tkdnd=E2=80=9D)`. Though this step might be done autom=
atically by Tcl::pTk depending on the syntax used.</div><div><br></div><div=
>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><br>=
</div><div>Also, be aware that there have been some recent changes since tk=
dnd 2.8 was released which address issues on macOS; <a href=3D"https://gith=
ub.com/petasis/tkdnd/commits/master" target=3D"_blank">https://github.com/p=
etasis/tkdnd/commits/master</a></div><div><br></div><div>Christopher A. Cha=
vez</div></div></div></div></div></blockquote></div>
--000000000000f57a66058a58bfa1--