Hi Sean, I don't have Term::Screen installed, but I checked its source - and it looks like whenever some 'non-function' (i.e., not navigational) key is pressed, getch() just gives out the corresponding symbol. Perhaps you'd just check for the spacebar and enter key values (32 and 10, respectively)?
Meanwhile, a bit of advice - if acceptable. ) Whenever you have a really multiple choice in your code AND you're able to use Perl 5.10 or later, at least consider using given-when construct instead of if-elsif-else one. -- iD 2012/2/19 Sean Murphy <smur7...@bigpond.net.au> > Hi All. > > I am trying to create my own CLI navigation program. I am using > Term::Screen since it is nice and simple. I am aware that there are other > modules out there which does all this. But I want to learn more about the > navigation of the cursor around the screen. Initially I am working with > something that I believe is simple and then I will migrate to Curses. But > not yet. > > I have been successful in creating the menu. The menu wraps. But I cannot > get the spacebar or enter key to be excepted. Below is the code: > > > #!/usr/bin/perl -w > > # Mac Perl 5.12 > > use strict; > require Term::Screen; > > my $scr = new Term::Screen; > my $win_col = $scr->cols(); > my $win_row = $scr-> rows(); > $scr->clrscr(); > $scr->at(0,0)->clreol()->puts ("window size: $win_row\t$win_col"); > > for (my $r = 2; $r <= $win_row; $r++) { > # prints menu. > my $item = $r -2; > $scr->at($r,10)->puts("$item - menu item $item"); > } #end while > my $curser_char = '_'; > $scr->at(2, 0)->puts($curser_char); > $scr->noecho(); > my $col = 0; > my $row = 2; > my $top_row = 2; > my $bottom_row = $win_row; > > while ( 1) { > my $key = $scr->getch(); > if ($key eq "kd") { > $scr->at($row, $col)->puts(' '); > ++$row; > $row = $top_row if ($row > $bottom_row); > } elsif ($key eq "ku") { > $scr->at($row, $col)->puts(' '); > --$row; > $row = $bottom_row if ($row < $top_row); > } else { > last if ($key eq 'ke'); > last if ($key eq 'q'); > } #end if > $scr->at($row, $col)->puts("$curser_char $row -"); > } # end while > > so how do you capture the Enter or Space? > > I have read the code for Term::Screen and it doesn't appear to have this > as one of the defined keys in the last routine. > > Sean > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >