RE: SimpleList drag and drop

Hi, I'm no expert on this, but read "perldoc Gtk2::Widget" for the
drag-n-drop callbacks.

I did (honestly!)

Usually, you don't drop onto the same widget, but for your example

$slist->signal_connect("drag_drop" => sub { warn "dropped\n";  } );

OK. That certainly gives me a dropped signal. But somehow the timing with the update of the tied data array 
is out. 

For the attached code, at the dropped signal, the array is still in its original order. Only when pressing 
the button (or redoing the drop) is the new order displayed.

Any ideas?

#!/usr/bin/perl -w

use strict;
use Gtk2 -init;
use Gtk2::SimpleList;

my $win = Gtk2::Window->new;
$win->signal_connect (delete_event => sub { Gtk2->main_quit; });

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";

$vbox->add ($slist);

my $button = Gtk2::Button->new ( 'Print List' );
$vbox->add ($button);
$button -> signal_connect(clicked => sub {list();});


sub list {
 for (0..$#{$slist->{data}}) {
  warn $slist->{data}[$_][0]." ".$slist->{data}[$_][1]."\n";

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]