LibUI::EditableCombobox - Single-Selection Control with a Drop Down Menu of Predefined Options or Enter Your Own
use LibUI ':all'; use LibUI::VBox; use LibUI::Window; use LibUI::EditableCombobox; Init( { Size => 1024 } ) && die; my $window = LibUI::Window->new( 'Hi', 320, 100, 0 ); my $box = LibUI::VBox->new(); my $combo = LibUI::EditableCombobox->new(); my @langs = ( qw[English French Klingon German Japanese], 'Ubbi dubbi' ); $combo->append($_) for @langs; $box->append( $combo, 0 ); $combo->onChanged( sub { warn 'Language: ' . shift->text }, undef ); $window->setChild($box); $window->onClosing( sub { Quit(); return 1; }, undef ); $window->show; Main();
A LibUI::EditableCombobox object represents a control to select one item from a predefined list of items or enter ones own.
A customary item can be entered by the user via an editable text field.
Not a lot here but... well, it's just a simple widget.
new( )
my $lst = LibUI::EditableCombobox->new( );
Creates a new combo box.
append( )
$lst->append( 'English' );
Appends an item to the editable combo box.
onChanged( ... )
$lst->onChanged( sub { my ($ctrl, $data) = @_; warn $ctrl->text; }, undef);
Registers a callback for when an editable combo box item is selected or user text changed.
Expected parameters include:
$callback
$lst
$data
Note: The callback is not triggered when calling setText( ... ).
setText( ... )
$lst->setText( 'Icelandic' );
Sets the editable combo box text.
text( )
if($lst->selected eq 'English') { ...; }
Returns the text of the editable combo box.
This text is either the text of one of the predefined list items or the text manually entered by the user.
LibUI::Combobox
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Sanko Robinson <sanko@cpan.org>
To install LibUI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LibUI
CPAN shell
perl -MCPAN -e shell install LibUI
For more information on module installation, please visit the detailed CPAN module installation guide.