munichunixguy has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perlers,

I've run into a bug in Curses::UI that means I have to abandon it if I can't find a solution. I've got an entry mask and I'm enforcing some rules, such as that particular fields may not be left empty. I'm using "-onblur" on TextEntry widgets to call a function which checks validity, and if the content is invalid:
1) calls "$root->dialog()" to notify the user and
2) sets focus back to the widget that was just left.

This works fine if the following widget is another TextEntry, but if the next is a Popupmenu widget, the Popupmenu widget gets highlighted, while the actual focus is still in the TextEntry widget, but with no cursor. This is totally misleading for a user and unacceptable.

The mainainer doesn't return emails. Does anyone have any suggestions? I include a reproducer below.

cheers,

Munichunixguy

#!/usr/bin/perl use Curses::UI; my $Cui = new Curses::UI ( -color_support => 1, -clear_on_exit => 1, -debug => 0, ); my $win = $Cui->add('win', 'Window', -title => 'Title', -border => 1,) +; #------------------------------------------------------ # username #------------------------------------------------------ $win->add('unlab', 'Label', -x => 0, -y => 1, -text => 'Username', -bold => 1, -bg => 'blue'); $win->add('unte', 'TextEntry', -x => 10, -y => 1, -width => 10, # add a binding to reset focus to pwte if field is empty -onblur => \&check_username); #------------------------------------------------------ # type #------------------------------------------------------ $win->add('tylab', 'Label', -x => 25, -y => 1, -text => 'Type', -bold => 1, -bg => 'blue'); $win->add('typom', 'Popupmenu', -x => 30, -y => 1, -values => [ 1, 2, 3 ], -labels => { 1 => 'one', 2 => 'two', 3 => 'three' }, -width => 7, ); #------------------------------------------------------ # password #------------------------------------------------------ $win->add('pwlab', 'Label', -x => 40, -y => 1, -text => 'Password', -bold => 1, -bg => 'blue'); $win->add('pwte', 'TextEntry', -x => 50, -y => 1, -width => 10); # add a binding to quit $win->set_binding( sub { exit; }, "\cQ"); $Cui->mainloop; # subs sub check_username { my $this = shift; if (!length($this->get)) { $this->root->dialog( -message => 'Username cannot be empty', -title => 'Error', ); $this->focus; return; } }

Replies are listed 'Best First'.
Re: is Curses::UI hopelessly broken?
by Anonymous Monk on Aug 18, 2014 at 07:04 UTC