LibUI::Combobox - Single-Selection Control with a Drop Down Menu of Predefined Options
use LibUI ':all'; use LibUI::VBox; use LibUI::Window; use LibUI::Combobox; Init( { Size => 1024 } ) && die; my $window = LibUI::Window->new( 'Hi', 320, 100, 0 ); my $box = LibUI::VBox->new(); my $combo = LibUI::Combobox->new(); my @langs = ( qw[English French Klingon German Japanese], 'Ubbi dubbi' ); $combo->append($_) for @langs; $box->append( $combo, 0 ); $combo->onSelected( sub { warn 'Language: ' . $langs[ shift->selected ] }, undef ); $window->setChild($box); $window->onClosing( sub { Quit(); return 1; }, undef ); $window->show; Main();
A LibUI::Combobox object represents a control to select one item from a predefined list of items via a drop down menu.
Not a lot here but... well, it's just a simple widget.
new( )
my $lst = LibUI::Combobox->new( );
Creates a new combo box.
append( )
$lst->append( 'English' );
Appends an item to the combo box.
clear( )
$lst->clear( );
Deletes all items from the combo box.
delete( ... )
$lst->delete( 4 );
Deletes an item at $index from the combo box.
$index
insertAt( ... )
$lst->insertAt( 10, 'Klingon' );
Inserts an item at $index to the combo box.
numItems( )
my $count = $lst->numItems;
Returns the number of items contained within the combo box.
onSelected( ... )
$lst->onSelected( sub { my ($ctrl, $data) = @_; warn $ctrl->value; }, undef);
Registers a callback for when a combo box item is selected.
Expected parameters include:
$callback
$lst
$data
Note: The callback is not triggered when calling setSelected( ... ).
setSelected( ... )
selected( )
if($lst->selected == 5) { ...; }
Returns the index of the item selected. -1 is returned on empty selection.
-1
$lst->setSelected( 50 );
Sets the item selected.
LibUI::EditableCombobox
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.