develooper Front page | perl.tcltk | Postings from June 2019

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

Thread Previous
From:
welle ozean via tcltk
Date:
June 2, 2019 15:17
Subject:
Re: [macOS] Tcl::pTk Drag&Drop
Message ID:
CAL0NCLumi3wJMVUg1gRgfD=YSLDO5ufRymBKVfHvux0PiTgVsg@mail.gmail.com
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 = 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 <
chrischavez@gmx.us>:

> (Trying to send this to the list again for reference and to see if I can
> send emails now. It didn’t 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 <tcltk@perl.org> 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 => [\&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
>
>
> 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’s needed to use it;
> I don’t 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”)`. 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’s 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
>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About