The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

LibUI::EditableCombobox - Single-Selection Control with a Drop Down Menu of Predefined Options or Enter Your Own

SYNOPSIS

    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();

DESCRIPTION

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.

Functions

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 - CodeRef that should expect the following:
$lst - backreference to the instance that initiated the callback
$data - user data registered with the sender instance
$data - user data to be passed to the callback

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.

See Also

LibUI::Combobox

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>