Skip Menu |

This queue is for tickets about the Curses-UI CPAN distribution.

Report information
The Basics
Id: 78567
Status: new
Priority: 0/
Queue: Curses-UI

People
Owner: Nobody in particular
Requestors: persson [...] katamail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.9607
Fixed in: (no value)



Subject: Crash (?) upon setting keybinding
Perhaps it's just me doing something wrong, but I'm not able to set a callback for arbitrary keys on a ListBox. Basically, I want my callback function to be called when the user hits "i" (or any other key, for that matter) on a ListBox. Here's how I'm doing it: #!/usr/bin/perl -w use strict; use Curses::UI; # Create the root object. my $cui = new Curses::UI ( -clear_on_exit => 0, ); # create a window to contain the listbox my $win = $cui->add('win', 'Window', -title => "Container window" ); my $v = [ 1, 2, 3 ]; my $l = { 1 => 'One', 2 => 'Two', 3 => 'Three' }; # the callback function sub my_callback { my $listbox = shift; my $label = $listbox->parent->getobj('label'); my ($id, $value) = ($listbox->get_active_id(), $listbox->get_active_value()); $label->text("Currently selected id $id, value $value"); } # add a label to the window, to print stuff $win->add( 'label', 'Label', -y => -1, -text => "Here's where messages appear...", -width => -1, ); # add the listbox to the window $win->add( undef, 'Listbox', -y => 8, -padbottom => 2, -values => $v, -labels => $l, -width => 20, -border => 1, -title => 'Listbox', -vscrollbar => 1, -onchange => \&my_callback, ); # Bind <CTRL+Q> to quit. $cui->set_binding( \&exit, "\cQ" ); $cui->set_binding( \&my_callback, "i" ); $win->focus; $cui->mainloop; ------------------- When I run this, the callback is called when I hit "enter" as expected, but when I hit "i" the program just terminates. I tried doing $win->set_binding instead of $cui->set_binding, but the result is the same. Is this a bug or am I doing something wrong? Thanks for any help.