use strict; use Wx; ############################## package MyApp; use base qw(Wx::App); sub OnInit { my($this) = shift; my($frame) = MyFrame->new; $frame->Show(1); $this->SetTopWindow($frame); return 1; } ############################## package MyFrame; use base qw(Wx::Frame); use Wx::DND; use Wx::Event qw(EVT_LIST_BEGIN_DRAG); sub new { my($class) = shift; my $this = $class->SUPER::new(undef, -1, 'test'); $this->{listbox} = Wx::ListBox->new($this, -1, [0,0], [180,200]); $this->{listbox2} = Wx::ListBox->new($this, -1, [200,0], [180,200]); $this->{listbox}->InsertItems(['foo'], 'end'); $this->{listbox}->InsertItems(['bar'], 'end'); EVT_LIST_BEGIN_DRAG($this->{listbox}, $this->{listbox}, \&OnDrag); EVT_LIST_BEGIN_DRAG($this->{listbox2}, $this->{listbox2}, \&OnDrag); return $this; } sub OnDrag { my( $this, $event ) = @_; my $data = Wx::TextDataObject->new($this); my $source = Wx::DropSource->new($this); $source->SetData($data); $source->DoDragDrop(1); $source->InsertItems([$data], 'end'); } ############################## package main; my ($app) = MyApp->new(); $app->MainLoop();