Re: drag and drop with clist
- From: René Seindal <rene seindal dk>
- To: Dan Espen <dane mk telcordia com>
- Cc: Mike Nielsen <miken bigpond net au>, Gtk-Perl List <gtk-perl-list gnome org>
- Subject: Re: drag and drop with clist
- Date: Thu, 20 Feb 2003 21:10:48 +0100
On Wed, Feb 19, 2003 at 02:54:16PM -0500, Dan Espen wrote:
Mike Nielsen <miken bigpond net au> writes:
Dan,
Well done!
Would you mind posting a sample of how you made it work?
Otherwise, here are the necessary parts:
$clist->set_reorderable($true); # allow drag/drop
$clist->signal_connect('row_move', \&RowMove );
Thanks a million! I had done this with manual drag-n-drop, but this is
like 50 lines of code less. Thanks.
sub RowMove {
my ($widget,$row_from,$row_to) = @_;
my @chunk=splice @AoA, $row_from, 1; # extract piece
splice @AoA, $row_to, 0, @chunk; # put it back
}
In this case, @AoA has my application data which I need to
keep in the same order as the displayed list.
You can handle that by attaching your stuff as row data, use
$list->set_row_data($row => $data)
and
$list->get_row_data($row)
to set and get it. Put it there at the beginning and get it back in
order afterwards.
This is only lightly tested, but it seems to be doing the job.
Its so simple, I don't know why everything else I looked at
seemed so complicated.
Works for me, with the titles displayed.
Thanks.
--
René Seindal (rene seindal dk) http://sights.seindal.dk/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]