Re: Cut and paste on HList::Tree

Marc Dashevsky <[email protected]> Fri, 30 Mar 2007 15:45:32 -0400
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
At 11:39 AM 3/30/2007, you wrote:
>Hi,
> 
>I'm trying to implement cut and paste functionality on a Tree widget, basically when the user selects one entry and right-click a menu shows up with the options Cut, Copy, Paste before, Paste after. Cut and copy work fine, paste works when the new entry is inserted at the end of the tree but the program crashes when I use options -at, -before and -after.
>Any help will be greatly appreciated.
> 
>Thanks
>Patricia
> 
>This is the part of my script that crashes
>    $menu = $db->Menu(
>        -tearoff   => 0,
>        -menuitems =>[ 
>            ['command'=>'Paste Before', 
>                 -command => sub{
>                     print "Paste Before \n";
>                     $parent = $tests_list->infoParent($index[0]);
># This works         $tests_list->addchild($parent, -text => $item_sel);
># Next 2 crash
>                     $tests_list->add($parent,-before =>$index[0], -text => $item_sel);
>                     $tests_list->add($parent,-at=>1, text=>$item_sel
>                }
>            ],

It's a known bug.  Move -at and -before options to the end of the list to work around, i.e.:

        $tests_list->add($parent, -text => $item_sel, -before => $index[0]);
        $tests_list->add($parent, -text => $item_sel, -at => 1);

Marc  

--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk