Hey,

I've been working my a-s off trying to make this work as I want with no luck. So, now I turn myself towards your wisdom. I have been working on this Tk::ColumnView module, and I just can't get the Drag&Drop to work as I want. I've broken it down to the relevant parts:
use Tk; use Tk::HList; use Tk::Pane; use Tk::DragDrop; use strict; use warnings; my $mw = MainWindow->new; my $pane = $mw->Scrolled('Pane', -width => 800, -height => 400, -sticky => 'nsew', -scrollbars => 'os', )->pack(-fill => 'both', -expand => 1); addCol(1); addCol(2); addCol(3); sub addCol { my $id = shift; my $width = 200; my $frame = $pane->Frame( -relief => "ridge", -bd => 1, -width => $width, )->pack(-side => 'left', -fill => 'both', -expand => 1, ); # DnD SUPPORT! #my $frame1 = $frame->Frame()->pack(); #my $frame2 = $frame->Frame()->pack(); my $drag_source = $frame->DragDrop( -event => '<B1-Motion>', -sitetypes => [qw/Local/], ); my $adjuster = $pane->Adjuster(); $adjuster->packAfter($frame, -side => 'left'); my $label = $frame->Label(-width => 30, -text => "Test" . $id, )->pack(-fill => "both"); my $hlist = $frame->Scrolled("HList", -scrollbars => 'osoe', -selectmode => 'extended' )->pack(-fill => "both", -expand => 1); } MainLoop;
Basicly, I want the possability to be able to drag, say the title (Label) at the top either to the left or right, and drop it anywhere (in the pane I suppose). After that the idea is to rearrange the columns. So, basicly, I wanna be able of rearranging the columns by drag&drop. I read some tutorial on the web (and I have some code in here from that), but if I put the label I wanna have dragable in the $drag_source, the whole label "disapears". Or, well, it seems to be there, but its not packed properly (height 1 pixel or something..?) The idea with 2 frames ($frame1 and $frame2) was to make just ONE of those frames dragable, so I wouldnt get wierd things happening, when it may think I wanna drag the HList. That is, but Label on one frame, and the HList on the other.

Else the layout should be as I want it when the script is ran as is.

Natrually, I need something to be a DropSite to. Appreciate help on that too! Suppose the pane is a good kandidate.

As a plus, it would also be nice to somehow show a "ghost" of the column dragged while dragging. Would be nice if anyone here knew how to do that aswell!

Thanks,
Ace

In reply to Drag & Drop Problem by Ace128

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.