Skip Menu |

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

Report information
The Basics
Id: 27034
Status: open
Priority: 0/
Queue: Curses-UI

People
Owner: Nobody in particular
Requestors: john [...] nixnuts.net
Cc:
AdminCc:

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



Subject: Listbox focus broken
The Listbox focus method occasionally fails to set '-focus' on the object. In the attached example you can see that the listbox has the proper focus (you can change the selection), but the display isn't being drawn correctly until you tab out of the listbox then back in. If you uncomment the $radio->{'-focus'} = 1; line the display will draw correctly without tabbing out of the listbox.
Subject: cui-bug.pl
#!/usr/bin/perl # use Curses::UI; my $cui = Curses::UI->new( '-color_support' => 1); $cui->set_binding( sub { exit; }, 'q', "\cC" ); my $win = $cui->add( 'Window1' => 'Window', '-border' => 1, '-y' => 1, '-fg' => 'blue', '-bfg' => 'green', '-tfg' => 'green', '-sfg' => 'green', '-title' => 'Window 1', ); $win->set_binding( sub { exit; }, 'q', "\cC" ); my $radio = $win->add( 'Window1.radiobox' => 'Listbox', '-radio' => 1, '-height' => 3, '-values' => [ 'this', 'that', 'another' ], '-selected' => 1, '-y' => 3, '-x' => 2, ); $win->add( 'Window1.nextbutton' => 'Buttonbox', '-buttonalignment' => 'middle', '-padbottom' => 0, '-buttons' => [ { '-label' => '[Next]', '-onpress' => sub { shift->parent->loose_focus; }, }, ], '-y' => 7 ); $radio->focus(); ### Why doesn't -focus get set properly? ### # $radio->{'-focus'} = 1; $win->onFocus( sub { $radio->focus() } ); $win->modalfocus(); $cui->delete('Window1'); exit;
... 11 years later, I got the same problem. No maintainer there for this greate module?
Subject: This fixes this issue
root@wawicwdev:/opt/server# diff -U 5 /usr/local/share/perl/5.24.1/Curses/UI/Container.pm.org /usr/local/share/perl/5.24.1/Curses/UI/Container.pm --- /usr/local/share/perl/5.24.1/Curses/UI/Container.pm.org 2018-05-16 20:07:52.262476330 +0200 +++ /usr/local/share/perl/5.24.1/Curses/UI/Container.pm 2018-05-16 20:08:04.654679126 +0200 @@ -409,11 +409,11 @@ } } # Change the draworder if a focusable objects was found. - if ($forced or defined $new_obj and $new_obj ne $cur_obj) + if ($forced or ((defined $new_obj) and (($new_obj ne $cur_obj) or (!$new_obj->{-focus})))) { my $idx = $this->draworder_id2idx($new_id); my $move = splice(@{$this->{-draworder}}, $idx, 1); push @{$this->{-draworder}}, $move; root@wawicwdev:/opt/server#