perl - Curses::UI - How to close a window? -


how close win2 when pressing "back"-button?

#!/usr/bin/env perl use warnings; use 5.012; use curses::ui; $curses::ui::debug = 0; $list = [ qw( use libraries distribution instead of system ) ]; %hash; $y=0; $x_1=0; $width_1=14; $x_2=16; $width_2=30;  $cui = new curses::ui(  -color_support => 1 ); $win1 = $cui->add( "win1", 'window', );  $entry ( @$list ) {     $win1->add( undef, 'textentry', -x => $x_1, -y => $y, -width => $width_1,          -text => $entry, -focusable => 0, -readonly => 1, );     $hash{$entry} = $win1->add( $entry, 'textentry', -x => $x_2, -y => $y,          -width => $width_2, -focusable => 1, -readonly => 0, );     $y++; } $but1 = $win1->add(  "addbutton1", 'buttonbox',          -buttons => [ { -label => "< ok >", -onpress => \&add } ],          -x => 5, -y => $y + 2 );  sub add {      $y = 0;     $win2 = $cui->add( "win2", 'window', );     $entry ( @$list ) {         $input = $hash{$entry}->get();         $win2->add( undef, 'textentry', -x => $x_1, -y => $y, -width => $width_1,             -text => $entry, -focusable => 0, -readonly => 1, -bg => 'cyan' );         $win2->add( $y, 'textentry', -x => $x_2, -y => $y, -width => $width_2,             -text => $input, -focusable => 0, -readonly => 1, -bg => 'cyan' );         $y++;     }     $but2 = $win2->add(  "addbutton2", 'buttonbox',          -buttons => [{ -label => "< >", ###         -onpress => sub{ $win1->focus() }}], -x => 5, -y => $y + 2 );     sub add2 { $win1->focus(); };     $win2->focus(); }  $cui->mainloop; 

call delete method on $cui.

@@ -32,7 +32,7 @@      }      $but2 = $win2->add(  "addbutton2", 'buttonbox',           -buttons => [{ -label => "", ### -        -onpress => sub{ $win1->focus() }}], -x => 5, -y => $y + 2 ); +        -onpress => sub{ $win1->focus(); $cui->delete('win2') }}], -x => 5, -y => $y + 2 );      sub add2 { $win1->focus(); };      $win2->focus();  } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -