Re: SimpleList drag and drop- works better
- From: zentara <zentara1 sbcglobal net>
- To: gtk-perl-list gnome org
- Subject: Re: SimpleList drag and drop- works better
- Date: Fri, 22 Sep 2006 11:31:40 -0400
On Fri, 22 Sep 2006 11:22:37 +0200
"Ratcliffe, Jeffrey (Peters)" <Jeffrey Ratcliffe External eads com> wrote:
Try this, I promise it works, but it may not be the optimum event
to look for.
And work it does very nicely, thank you. If someone wants to suggest a better event, I am all ears, but for
the moment it does the job.
Hi again, this does it properly, (I think), without a global flag,
and using the proper signals instead of watching events.
The key is to use the drag_end signal instead of drag_drop
#!/usr/bin/perl
use warnings;
use strict;
use Gtk2 -init;
use Gtk2::SimpleList;
my $win = Gtk2::Window->new;
$win->signal_connect (delete_event => sub { Gtk2->main_quit; });
$win->set_size_request(500,400);
$win->set_position('center');
my $vbox = Gtk2::VBox->new;
$win->add ($vbox);
my $slist = Gtk2::SimpleList->new ( 'Int' => 'int', 'Text' => 'text' );
@{$slist->{data}} = ( [1, 'text1'], [2, 'text2'], [3, 'text3'] );
$slist -> set_reorderable( 1 );
#$slist -> signal_connect("drag_drop" => sub {
# warn "dropped!\n";
# return 0;
#});
$slist->signal_connect ("drag_end" => sub {
list();
return 0;
});
$vbox->add ($slist);
my $button = Gtk2::Button->new ( 'Print List' );
$vbox->add ($button);
$button -> signal_connect(clicked => sub {list();});
$win->show_all;
Gtk2->main;
###############################################
sub list {
# print @{$slist->{data}},"\n";
for (0..$#{$slist->{data}}) {
warn $slist->{data}[$_][0]." ".$slist->{data}[$_][1]."\n";
}
}
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]