NAME
LibUI::Combobox - Single-Selection Control with a Drop Down Menu of Predefined Options
SYNOPSIS
use LibUI ':all';
use LibUI::VBox;
use LibUI::Window;
use LibUI::Combobox;
Init && die;
my $window = LibUI::Window->new( 'Hi', 320, 100, 0 );
$window->setMargined( 1 );
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();
DESCRIPTION
A LibUI::Combobox object represents a control to select one item from a predefined list of items via a drop down menu.
Functions
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.
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
- CodeRef that should expect the following:$data
- user data to be passed to the callback
Note: The callback is not triggered when calling setSelected( ... )
.
selected( )
if($lst->selected == 5) {
...;
}
Returns the index of the item selected. -1
is returned on empty selection.
setSelected( ... )
$lst->setSelected( 50 );
Sets the item selected.
See Also
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Sanko Robinson <sanko@cpan.org>