http://www.perlmonks.org?node_id=951130

ghosh123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I need one push in regard to move a row element up and down by clicking a button or pressing Up/Down key. Let us consider this small code below ================================================
my $mw = MainWindow -> new(); my $lb = $mw -> Scrolled("Listbox", -scrollbars=>'e' , ) -> pack( -side => 'left' , -fill => 'y' ); foreach my $key ("first" , "second" , "third", "fourth") { $lb -> insert( 'end', $key ); } $lb->activate ( 0 ) ; $lb->selectionSet ( 0 ) ; $lb->focus; $lb -> bind ('<Key-Down>', sub {print "Down\n"} ); $mw -> bind ('<Key-Up>', sub {print "\nUP"} ); MainLoop;
================================================== Now the items appear as "first", "second" ,"third" and "fourth" in row1 row2,row3 and row4 respectively. My requirement is to alter the order of appearence by clicking or pressing up/down key. For example after the order would appear as "second" "first" "fouth" and "third". Kindly help . Thanks in advance. -AG