asphyx has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I am trying to build a text-based interface for a Perl program.
I discovered Curses::UI on CPAN, which looks very handy. I tried http://search.cpan.org/~mdxi/Curses-UI-0.9605/lib/Curses/UI/Tutorial.pod and encountered some problems.
My cui and window are displayed correctly, but I'm unable to use any keyboard key, for example to quit the application.
In used the set_binding() method to define key, but I still cannot interact with the application.
I wonder if I made a mistake, or if this module is compatible with Win32.
Here is the short code I tried:
#!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Curses::UI; my $cui = new Curses::UI( -color_support => 1 ); my @menu = ( { -label => 'File', -submenu => [ { -label => 'Exit ^Q', -value => \&exit_dialog } ] }, ); sub exit_dialog() { my $return = $cui->dialog( -message => "Do you really want to quit?", -title => "Are you sure???", -buttons => ['yes', 'no'], ); exit(0) if $return; } my $menu = $cui->add( 'menu','Menubar', -menu => \@menu, -fg => "blue", ); my $win1 = $cui->add( 'win1', 'Window', -border => 1, -y => 1, -bfg => 'red', ); my $texteditor = $win1->add("text", "TextEditor", -text => "Here is some text\n" . "And some more"); $cui->set_binding(sub {$menu->focus()}, "\cX"); $cui->set_binding( \&exit_dialog , "\cQ"); $texteditor->focus(); $cui->mainloop();
Has anybody got some documentation about Curses::UI? I tried CPAN but I never managed to interact with any Curses app.
How do you bind key with Curses::UI? :)
Thank you in advance for any help,
Cheers from France.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Curses::UI binding problem on Perl v5.8.8 built for MSWin32-x86-multi-thread
by pileofrogs (Priest) on Oct 09, 2008 at 22:09 UTC |