Subject: | Undefined subroutine &main::loose_focus for widget Notebook |
The widget Notebook doesn't support function loose_focus. For example:
#v+
#!/usr/bin/perl
use strict;
use warnings;
use Curses::UI;
my ( $cui, $window, $notebook, %pages, $button);
$cui = new Curses::UI(
-clear_on_exit => 1,
-mouse_support => 1,
-debug => 1,
);
my $fh = "binding.log";
open STDERR, ">$fh";
$window = $cui->add(
'window','Window',
-border => 1,
);
$notebook = $window->add(
'notebook','Notebook',
-height => $window->height - 10,
);
$pages{1} = $notebook->add_page(
'test1'
);
$pages{2} = $notebook->add_page(
'test2'
);
$button = $window->add(
'button', 'Buttonbox',
-y => -1,
-x => 1,
-buttons => [
{
-label => '< Button1 >',
},
{
-label => '< Button2 >',
}
],
);
sub loose_focus1 {
my $this = shift;
$this->parent->getobj('button')->focus();
}
my $rbindings = $notebook->{-bindings};
my $rroutines = $notebook->{-routines};
${$rroutines}{'loose-focus'} = \&loose_focus1;
${$rbindings}{"\t"} = 'loose-focus';
$cui->set_binding( sub{exit(0)} , "\cq", "\cc");
$cui->mainloop;
#v-
For loose_focus I get:
#v+
DEBUG: get_key() -> [ ]
Undefined subroutine &main::loose_focus called at
/usr/share/perl5/vendor_perl/Curses/UI/Widget.pm line 1001.
#v-
For loose_focus1 it works, but loosing focus in this way is ugly.