From: Mattia B. <mb...@ds...> - 2002-02-14 21:45:49
|
> I've tried using wxFileDropTarget, but this didn't work, so I tried > wxDropTarget with the full OnData, OnDrop, wxFileDataObject set-up, but > couldn't get that to work. I'm going to do the obvious thing, which is look > for wxWindows examples, which I'll bet are out there, but can folks tell me: > - does wxPerl support all the drag-and-drop stuff? Should I not use the > FileDrop stuff, as I saw described as rather windows specific somewhere? It supports all the Dnd stuff wxWindows supports, _except_ DnD ( and cut'n'paste ) of user-defined data ( planned for a future version ). The rest should work. > - if anyone has a wxPerl drag-and-drop example, that would be great. sf.net/projects/wxperl/ -> samples -> download the samples for 0.06 demo/demo.pl -> Misc -> Drag&Drop shows TextDropTarget and BitmapDropTarget; below there is a FilesDropTarget --cut here-- package DNDFilesDropTarget; use base qw(Wx::FileDropTarget); sub new { my $class = shift; my $listbox = shift; my $this = $class->SUPER::new( @_ ); $this->{LISTBOX} = $listbox; return $this; } sub OnDropFiles { my( $this, $x, $y, $files ) = @_; $this->{LISTBOX}->Clear; Wx::LogMessage( "Dropped files at ($x, $y)" ); foreach my $i ( @$files ) { $this->{LISTBOX}->Append( $i ); } return 1; } --cut here-- BTW the demo for 0.08 was really unpolished, but the code works. HTH Mattia |