Home > Archive > PerlTk > April 2004 > Tk-804.026 final breaks Windows Drag and Drop
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Tk-804.026 final breaks Windows Drag and Drop
|
|
| H. Wade Minter 2004-03-26, 11:59 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I upgraded my app to Tk-804.026 from bribes, and sometime between the last
beta and the final, drag and drop broke on Win32.
Using the sample D&D script at
http://www.perltk.org/articles/dnd/localdnd.pl you can't drop when running
under .026. You can under a late beta.
Anyone want to dig in and see what changed between the two versions to
cause this problem?
- --Wade
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFAZIQOo4DwsyRGDscRAjcQAKDGszNckw62
+NakNgb7bfwPE2jatgCg1+Ir
zloMjJZCmMcYsEIYbNojH6E=
=ZhYe
-----END PGP SIGNATURE-----
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Nick Ing-Simmons 2004-03-27, 11:57 pm |
| H. Wade Minter <minter@lunenburg.org> writes:
>I upgraded my app to Tk-804.026 from bribes, and sometime between the last
>beta and the final, drag and drop broke on Win32.
>
>Using the sample D&D script at
>http://www.perltk.org/articles/dnd/localdnd.pl you can't drop when running
>under .026. You can under a late beta.
>
>Anyone want to dig in and see what changed between the two versions to
>cause this problem?
I did "tidy" Drag&Drop in .026 - but that script still works fine
on linux.
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| H.Wade Minter 2004-03-27, 11:57 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mar 27, 2004, at 8:57 AM, Nick Ing-Simmons wrote:
> H. Wade Minter <minter@lunenburg.org> writes:
>
> I did "tidy" Drag&Drop in .026 - but that script still works fine
> on linux.
Right - it works fine on Linux, but the drop is broken on Windows. It
seems to have broken between b16 and the final, so there was probably
some sort of subtle bug introduced.
Unfortunately, I don't know how to debug any further than that, but if
you run the script on Windows, you'll find that you can't drop.
- --Wade
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQFAZZ9lo4DwsyRGDscRAl6GAKDSnxHkV6Ni
EJEOVUh8rEQFJS6OPwCfdoKX
iMTLC2gOICf1WKSWLSyz2J0=
=W1uc
-----END PGP SIGNATURE-----
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Chris Whiting 2004-03-27, 11:57 pm |
|
"H.Wade Minter" <minter@lunenburg.org> wrote in message
news:758AE080-8004-11D8-8088-000A95A8D520@lunenburg.org...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> On Mar 27, 2004, at 8:57 AM, Nick Ing-Simmons wrote:
>
>
> Right - it works fine on Linux, but the drop is broken on Windows.
It does not work for me either (on Windows) . I can still do a drop from a
non Tk window to a Tk widget but cannot do a Local drop. Previously,
another process seemed to start for the dropsite but that no longer happens.
The drag works but the drop routine never gets launched.
>It
> seems to have broken between b16 and the final, so there was probably
> some sort of subtle bug introduced.
>
> Unfortunately, I don't know how to debug any further than that, but if
> you run the script on Windows, you'll find that you can't drop.
>
> - --Wade
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (Darwin)
>
> iD8DBQFAZZ9lo4DwsyRGDscRAl6GAKDSnxHkV6Ni
EJEOVUh8rEQFJS6OPwCfdoKX
> iMTLC2gOICf1WKSWLSyz2J0=
> =W1uc
> -----END PGP SIGNATURE-----
>
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> This message was posted through the Stanford campus mailing list
> server. If you wish to unsubscribe from this mailing list, send the
> message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Nick Ing-Simmons 2004-03-28, 10:22 pm |
| H . Wade Minter <minter@lunenburg.org> writes:
>
>Right - it works fine on Linux, but the drop is broken on Windows. It
>seems to have broken between b16 and the final, so there was probably
>some sort of subtle bug introduced.
>
>Unfortunately, I don't know how to debug any further than that, but if
>you run the script on Windows, you'll find that you can't drop.
Found and fixed that. Part of cleanup in .026 was to use ->PointToWindow
rather than ->containing. This fixed a snag where cursor was in the token
window that was being dragged and hence not "in" the site.
Snag was on Win32 PointToWindow just called a non-functional stub X
routine - no drops.
I implemented a Win32 version and it works again.
Still a snag with dropping from Explorer - but that looks like just
a .pm file fix.
--
Nick
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Nick Ing-Simmons 2004-03-28, 10:22 pm |
| Steve Schulze <smschulze11@comcast.net> writes:
>After poking at it a it, it appears that widget->toplevel->WindowId and
>widget->WindowId return different values, even if the window in question
>IS a toplevel window. For instance, the following demo script returns
>different values on Win98, perl 5.8.3, tk804.016, even though the docs
>suggest that they should be the same.
>
>#!/usr/bin/perl
>use warnings;
>use strict;
>use Tk;
>my $top = new MainWindow;
>my $listbox = $top->Listbox->pack;
>my $button = $top->Button(
> -text => 'Test',
> -command => sub{
> warn ${$listbox->toplevel->WindowId};
> warn ${$listbox->WindowId};
> }
> )->pack;
>MainLoop;
>
>This is apparently the reason DragDrop is failing on Windows.
>(widget->toplevel->WindowId == widget->WindowId) always evaluates to
>false. (See /Perl/site/lib/Tk/DragDrop/Rect.pm, line 50.)
In the above $listbox->toplevel is $top
and $top is not same window as $listbox so ids are supposed to differ.
But 'id' and such were to blame.
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Wade Minter 2004-03-28, 10:22 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mar 28, 2004, at 3:30 PM, Nick Ing-Simmons wrote:
> Found and fixed that. Part of cleanup in .026 was to use
> ->PointToWindow
> rather than ->containing. This fixed a snag where cursor was in the
> token
> window that was being dragged and hence not "in" the site.
> Snag was on Win32 PointToWindow just called a non-functional stub X
> routine - no drops.
>
> I implemented a Win32 version and it works again.
> Still a snag with dropping from Explorer - but that looks like just
> a .pm file fix.
Thanks for checking into this. Is a new release incorporating the fix
coming out this w end? If not, could you post a patch or something
so I could change it locally and get a fix out to the people who use my
app?
- --Wade
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQFAZzxto4DwsyRGDscRAu8QAKC9+H+yir0W
/4DfugJ3pnD9v93bSQCg817I
NX3YRCmoPbk+7xXjc23mrRw=
=1Ysu
-----END PGP SIGNATURE-----
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Nick Ing-Simmons 2004-03-28, 10:22 pm |
| Wade Minter <minter@lunenburg.org> writes:
>
>Thanks for checking into this. Is a new release incorporating the fix
>coming out this w end? If not, could you post a patch or something
>so I could change it locally and get a fix out to the people who use my
>app?
There is a composite patch of my sources relative to Tk804.026 at
http://www.ni-s.u-net.com/upload/Tk-804.026-patches.gz
I am waiting for a few confirmations that fixes work before making
a .027
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Jean-Louis MOREL 2004-03-29, 7:34 am |
| Dans l'article <A58BF2B6-80FA-11D8-BC58-000393C3212A@lunenburg.org>,
minter@lunenburg.org a dit...
>
>Thanks for checking into this. Is a new release incorporating the fix
>coming out this w end? If not, could you post a patch or something
>so I could change it locally and get a fix out to the people who use my
>app?
>
patched version of Tk .026 for Windows available on bribes :
http://www.bribes.org/perl/ppmdir.html
HTH
--
J-L.M.
| |
| H. Wade Minter 2004-03-29, 1:49 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, 28 Mar 2004, Nick Ing-Simmons wrote:
> There is a composite patch of my sources relative to Tk804.026 at
>
> http://www.ni-s.u-net.com/upload/Tk-804.026-patches.gz
>
> I am waiting for a few confirmations that fixes work before making
> a .027
The bribes PPD with that patch seems to fix part of the problem - you can
now drag and drop under Windows. But I've uncovered another D&D problem
that is affecting both Windows and Linux (Windows with the patchset, Linux
with 804.026 final unpatched).
I've attached a reduced testcase based on my code (dnd.pl). It will pop
up two windows - A listbox with a bunch of lines and a second window with
a checkbox and a label.
Drag one of the lines from the listbox to the space beside the F1: label,
and it will drop properly. You'll see the dropped text appear beside F1:.
Next, drag another line from the listbox and attempt to drop it on top of
the previous text. Up until 804.026 final, the new text would replace the
old text upon dropping. Now, however, you cannot drop the new text on top
of the old. The DropSite never appears to activate once there has already
been a drop, judging by the border of the D&D token. If you move to the
empty space to the right of the dropped text, though, you can drop the new
text.
So it appears that something has changed so that the DropSite defined
here:
$f1_frame->DropSite(
-droptypes => ['Local'],
-dropcommand => [ \&Hotkey_Drop, "f1" ]
);
Isn't accepting drops on the stuff that is IN the frame, only on the empty
frame itself:
$f1_frame->Checkbutton(
-text => "F1: ",
-variable => \$f1_cb
)->pack( -side => 'left' );
$f1_frame->Label(
-textvariable => \$fkeys{f1}->{title},
-anchor => 'w'
)->pack( -side => 'left' );
You can no longer drop on the Checkbutton or Label. That was possible in
the .026 betas and prior.
If someone else could confirm this, I'd appreciate it.
- --Wade
### dnd.pl ###
#!/usr/bin/perl
use warnings;
use Tk;
use Tk::DragDrop;
use Tk::DropSite;
our $f1_cb;
sub list_hotkeys
{
if ( !Exists($hotkeysbox) )
{
$hotkeysbox = $mw->Toplevel();
$hotkeysbox->withdraw();
$hotkeysbox->title("Hotkeys");
$hotkeysbox->Label( -text => "Currently defined hotkeys:" )->pack;
my $f1_frame = $hotkeysbox->Frame()->pack( -fill => 'x' );
$f1_frame->Checkbutton(
-text => "F1: ",
-variable => \$f1_cb
)->pack( -side => 'left' );
$f1_frame->Label(
-textvariable => \$fkeys{f1}->{title},
-anchor => 'w'
)->pack( -side => 'left' );
$f1_frame->DropSite(
-droptypes => ['Local'],
-dropcommand => [ \&Hotkey_Drop, "f1" ]
);
$hotkeysbox->update();
$hotkeysbox->deiconify();
$hotkeysbox->raise();
}
else
{
$hotkeysbox->deiconify();
$hotkeysbox->raise();
}
}
sub StartDrag
{
# Starts the drag for the hotkey drag-and-drop.
my ($token) = @_;
$current_token = $token;
my $widget = $current_token->parent;
my $event = $widget->XEvent;
my $index = $widget->nearest( $event->y );
if ( defined $index )
{
$current_token->configure( -text => "Dragging" );
my ( $X, $Y ) = ( $event->X, $event->Y );
$current_token->raise;
$current_token->deiconify;
$current_token->FindSite( $X, $Y, $event );
}
}
sub Hotkey_Drop
{
# Assigns the dragged token to the hotkey that it's dropped onto.
my ($fkey_var) = @_;
my $widget = $current_token->parent;
my (@selection) = $widget->curselection();
$text = $widget->get( $selection[0] );
print "DEBUG: The text is $text\n";
$fkeys{$fkey_var}->{id} = "1";
$fkeys{$fkey_var}->{filename} = "/tmp/foo.mp3";
$fkeys{$fkey_var}->{title} = $text;
}
$mw = MainWindow->new;
$mw->withdraw();
$mw->geometry("+0+0");
$mw->title("Mr. Voice");
$mw->minsize( 67, 2 );
our $searchboxframe = $mw->Frame();
$mainbox = $searchboxframe->Scrolled(
'Listbox',
-scrollbars => 'osoe',
-width => 100,
-setgrid => 1,
-selectmode => "extended"
)->pack(
-fill => 'both',
-expand => 1,
-side => 'top'
);
$searchboxframe->pack(
-side => 'bottom',
-fill => 'both',
-expand => 1
);
$dnd_token = $mainbox->DragDrop(
-event => '<B1-Motion>',
-sitetypes => ['Local'],
-startcommand => sub { StartDrag($dnd_token) }
);
foreach $i ( 1 .. 100 )
{
$mainbox->insert( 'end', "This is line $i" );
}
list_hotkeys();
$mw->deiconify();
$mw->raise();
MainLoop;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFAaEQLo4DwsyRGDscRAokJAKCOesTkL+Qx
7ksyHkeY3/V135mlcQCgkD7M
rqprl3sGQopH58uGeDmSsI0=
=sRgf
-----END PGP SIGNATURE-----
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Dean Arnold 2004-03-31, 3:35 pm |
| (Perl AS 5.8.3, Tk804.026+patches from www.bribes.org)
It appears an old Win32 D&D issue is still rearing its head.
When dropping from a Win32 Explorer into a TextUndo
(inside a linenumbertext), perl burps with this info:
..frame.frame1.lntext.frame.textundo 563 'Tk::Callback=ARRAY(0x367f460)'
The drop works fine, but the "noise" is a bit unwelcome...is there a fix for this ?
(I vaguely recall some old posting RE: hexhacking a library, but I think there
ought to be a better solution...)
TIA,
Dean Arnold
Presicient Corp.
www.presicient.com
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Nick Ing-Simmons 2004-04-03, 5:31 pm |
| Dean Arnold <darnold@presicient.com> writes:
>(Perl AS 5.8.3, Tk804.026+patches from www.bribes.org)
>
>It appears an old Win32 D&D issue is still rearing its head.
>When dropping from a Win32 Explorer into a TextUndo
>(inside a linenumbertext), perl burps with this info:
>
>.frame.frame1.lntext.frame.textundo 563 'Tk::Callback=ARRAY(0x367f460)'
>
>The drop works fine, but the "noise" is a bit unwelcome...is there a fix for this ?
>(I vaguely recall some old posting RE: hexhacking a library, but I think there
>ought to be a better solution...)
Found that one too.
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Nick Ing-Simmons 2004-04-03, 5:31 pm |
| H. Wade Minter <minter@lunenburg.org> writes:
>
>So it appears that something has changed so that the DropSite defined
>here:
>
> $f1_frame->DropSite(
> -droptypes => ['Local'],
> -dropcommand => [ \&Hotkey_Drop, "f1" ]
> );
>
>Isn't accepting drops on the stuff that is IN the frame, only on the empty
>frame itself:
>
> $f1_frame->Checkbutton(
> -text => "F1: ",
> -variable => \$f1_cb
> )->pack( -side => 'left' );
> $f1_frame->Label(
> -textvariable => \$fkeys{f1}->{title},
> -anchor => 'w'
> )->pack( -side => 'left' );
>
>You can no longer drop on the Checkbutton or Label. That was possible in
>the .026 betas and prior.
>
>If someone else could confirm this, I'd appreciate it.
I can confirm that is what it does, it is what it was meant to do.
This was a fix for the NoteBook and similar cases where sites which
were not visible (covered by other windows) never the less accepted the
drop. So now the drop is considered to occur on the topmost window which
contains the drop point. If that window does not accept drops then
drop fails.
If you make a good case I will see if I can cook up something
that allows a parent widget to accept drops that children don't want.
--
Nick
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Nick Ing-Simmons 2004-04-03, 5:31 pm |
| Steve Schulze <smschulze11@comcast.net> writes:
>Nick Ing-Simmons wrote:
>
>
>While you are cleaning things up; there is a warning on line 26 in
>/Perl/site/Tk/DragDrop/Win32Site.pm that appears to be left over
>debugging code. There is NO occassion where it will not be called if the
>InitSite routine is called.
Which was what it was debugging - once upon a time it wasn't being called.
Removed it.
>It doesn't /hurt/ anything, but it clutters
>the console window unecessarily.
I also removed the even more anoying debug message from the C
code which snoops event queue to catch drop messages.
And I made Win32Site pass args to client handler so that
it thinks Explorer drops pass a STRING target.
(Win32 really only has CLIPBOARD as a selection, and that only
handles STRING as a target.)
>
>Regards,
>
>Steve
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| H. Wade Minter 2004-04-03, 6:31 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sat, 3 Apr 2004, Nick Ing-Simmons wrote:
> I can confirm that is what it does, it is what it was meant to do.
> This was a fix for the NoteBook and similar cases where sites which
> were not visible (covered by other windows) never the less accepted the
> drop. So now the drop is considered to occur on the topmost window which
> contains the drop point. If that window does not accept drops then
> drop fails.
>
> If you make a good case I will see if I can cook up something
> that allows a parent widget to accept drops that children don't want.
Well, it breaks functionality with my app, where I use the entire frame,
regardless of contents, as a dropsite. Now, the drops are basically
failing when there's value in the label, which means that the drops only
work as expected the first time they're used, in the empty frame.
If the current behavior is the correct one, that's , I just need to
know what the right way to get the functionality is. I've got a frame
that contains a checkbutton and a label, and the label may or may not have
any value in its textvariable. I need the user to be able to drop
anywhere in that region to assign the dropped value. How do I do that?
Set up a dropsite for the frame, checkbutton, and label all three?
- --Wade
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFAbymFo4DwsyRGDscRAkYRAJ9Bz4g0TWp1
qmexQ0FGSGPSa0bDXwCgpASz
ZtpRCI9Rd/Jgc8noPJguh88=
=WKCf
-----END PGP SIGNATURE-----
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Nick Ing-Simmons 2004-04-04, 7:31 am |
| H. Wade Minter <minter@lunenburg.org> writes:
>
>Well, it breaks functionality with my app, where I use the entire frame,
>regardless of contents, as a dropsite. Now, the drops are basically
>failing when there's value in the label, which means that the drops only
>work as expected the first time they're used, in the empty frame.
>
>If the current behavior is the correct one, that's , I just need to
>know what the right way to get the functionality is. I've got a frame
>that contains a checkbutton and a label, and the label may or may not have
>any value in its textvariable. I need the user to be able to drop
>anywhere in that region to assign the dropped value. How do I do that?
>
>Set up a dropsite for the frame, checkbutton, and label all three?
That should work but I will see if I can make your app work and
keep the NoteBook case fixed.
>
>- --Wade
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.2.4 (FreeBSD)
>
> iD8DBQFAbymFo4DwsyRGDscRAkYRAJ9Bz4g0TWp1
qmexQ0FGSGPSa0bDXwCgpASz
>ZtpRCI9Rd/Jgc8noPJguh88=
>=WKCf
>-----END PGP SIGNATURE-----
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| H. Wade Minter 2004-04-07, 12:49 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, 4 Apr 2004, Nick Ing-Simmons wrote:
> H. Wade Minter <minter@lunenburg.org> writes:
>
> That should work but I will see if I can make your app work and
> keep the NoteBook case fixed.
To get my app working again (I've pulled the downloads for the app until I
can get D&D fixed), and I'm trying to get the multiple dropsites
(checkbutton, frame, label) working. However, I'm getting a weird error
when I make my first drop. Any suggestions as to next steps?
[minter@localhost minter]$ ./dnd.pl
DEBUG: The text is This is line 7
Don't know how to handle magic of type \165 at
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi/Tk.pm line 406.
Don't know how to handle magic of type \165 at
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi/Tk/MainWindow.pm
line 166.
END failed--call queue aborted.
Don't know how to handle magic of type \165.
END failed--call queue aborted.
[minter@localhost minter]$
### dnd.pl ###
#!/usr/bin/perl
use warnings;
use Tk;
use Tk::DragDrop;
use Tk::DropSite;
our $f1_cb;
sub list_hotkeys
{
if ( !Exists($hotkeysbox) )
{
$hotkeysbox = $mw->Toplevel();
$hotkeysbox->withdraw();
$hotkeysbox->title("Hotkeys");
$hotkeysbox->Label( -text => "Currently defined hotkeys:" )->pack;
my $f1_frame = $hotkeysbox->Frame()->pack( -fill => 'x' );
$f1_cb = $f1_frame->Checkbutton(
-text => "F1: ",
-variable => \$f1_cb
)->pack( -side => 'left' );
$f1_lab = $f1_frame->Label(
-textvariable => \$fkeys{f1}->{title},
-anchor => 'w'
)->pack( -side => 'left' );
$f1_frame->DropSite(
-droptypes => ['Local'],
-dropcommand => [ \&Hotkey_Drop, "f1" ]
);
$f1_cb->DropSite(
-droptypes => ['Local'],
-dropcommand => [ \&Hotkey_Drop, "f1" ]
);
$f1_lab->DropSite(
-droptypes => ['Local'],
-dropcommand => [ \&Hotkey_Drop, "f1" ]
);
$hotkeysbox->update();
$hotkeysbox->deiconify();
$hotkeysbox->raise();
}
else
{
$hotkeysbox->deiconify();
$hotkeysbox->raise();
}
}
sub StartDrag
{
# Starts the drag for the hotkey drag-and-drop.
my ($token) = @_;
$current_token = $token;
my $widget = $current_token->parent;
my $event = $widget->XEvent;
my $index = $widget->nearest( $event->y );
if ( defined $index )
{
$current_token->configure( -text => "Dragging" );
my ( $X, $Y ) = ( $event->X, $event->Y );
$current_token->raise;
$current_token->deiconify;
$current_token->FindSite( $X, $Y, $event );
}
}
sub Hotkey_Drop
{
# Assigns the dragged token to the hotkey that it's dropped onto.
my ($fkey_var) = @_;
my $widget = $current_token->parent;
my (@selection) = $widget->curselection();
$text = $widget->get( $selection[0] );
print "DEBUG: The text is $text\n";
$fkeys{$fkey_var}->{id} = "1";
$fkeys{$fkey_var}->{filename} = "/tmp/foo.mp3";
$fkeys{$fkey_var}->{title} = $text;
}
$mw = MainWindow->new;
$mw->withdraw();
$mw->geometry("+0+0");
$mw->title("Mr. Voice");
$mw->minsize( 67, 2 );
our $searchboxframe = $mw->Frame();
$mainbox = $searchboxframe->Scrolled(
'Listbox',
-scrollbars => 'osoe',
-width => 100,
-setgrid => 1,
-selectmode => "extended"
)->pack(
-fill => 'both',
-expand => 1,
-side => 'top'
);
$searchboxframe->pack(
-side => 'bottom',
-fill => 'both',
-expand => 1
);
$dnd_token = $mainbox->DragDrop(
-event => '<B1-Motion>',
-sitetypes => ['Local'],
-startcommand => sub { StartDrag($dnd_token) }
);
foreach $i ( 1 .. 100 )
{
$mainbox->insert( 'end', "This is line $i" );
}
list_hotkeys();
$mw->deiconify();
$mw->raise();
MainLoop;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFAdAaMo4DwsyRGDscRAkNpAJoCiMtpRzoc
jz0g43C+PcaMShp10QCcDa6E
0A4hx4dGCoYJ3xBXvGCZNE0=
=9Wfe
-----END PGP SIGNATURE-----
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| H. Wade Minter 2004-04-12, 8:35 pm |
| H. Wade Minter <minter@lunenburg.org> wrote:
>
> To get my app working again (I've pulled the downloads for the app until I
> can get D&D fixed), and I'm trying to get the multiple dropsites
> (checkbutton, frame, label) working. However, I'm getting a weird error
> when I make my first drop. Any suggestions as to next steps?
For anyone who's curious, the problem was on my end. When I made multiple
DropSites to match the new behavior in 804.026+, I named my Checkbutton
and the variable it was watching the same thing.
> $f1_cb = $f1_frame->Checkbutton(
> -text => "F1: ",
> -variable => \$f1_cb
> )->pack( -side => 'left' );
D'oh.
--Wade
|
|
|
|
|