NAME

Tk::MatchingBE - A single-selection BrowseEntry with 'matching' Entry widget

SYNOPSIS

require Tk::MatchingBE;

$mw->MatchingBE(-choices => [qw/foo bar baz/])->pack;

DESCRIPTION

Tk::MatchingBE is a Tk::BrowseEntry which allows for a single selection from a given list of choices/options. In order to find the right item in the choices list, the Entry widgets content is matched against the lists elements as the user types. The first matching item gets selected and the list is popped up if a match occurs. Key-press events causing non-matching content of the Entry are ignored. The only exception here are 'Delete' events. Matching is case insensitive and metacharacters are disabled (\Q). '<Return>' will select the active entry, popdown the list and trigger -selectcmd. Possible states of the widget are undef or a single selection - accessible per value or index. Tk::MatchingBE is a Tk::BrowseEntry derived widget.

METHODS

Tk::MatchingBE supports the following methods:

choices([qw/a list of possible choices/])

Get/Set the choices list (arrayref).

get_selected_index

Get the selected index.

set_selected_index(anInteger)

Set the selected index.

get_selected_value

Get the selected value. No setter here, as values need not be unique.

OPTIONS

Tk::ChoicesSet supports the following options:

-choices

Get set the list of possible choices.

-selectcmd

A callback to be called when the user selects an entry.

EXAMPLE

use Tk;
use Tk::MatchingBE;

my $mw = tkinit;
my $be = $mw->MatchingBE(-choices=>[qw/aaa bbb ccc ddd asd/])->pack;
$be->set_selected_index(0);
$mw->Button(-text => 'selected',
            -command => sub{
                for (qw/get_selected_index
                        get_selected_value/){
                    print $be->$_, "\n";
                }
            },
        )->pack;

$mw->Button(-text => 'next_item',
            -command => sub{
                my $i = $be->get_selected_index;
                $i = ($i+1) % 5 ;
                $be->set_selected_index($i);
            },
        )->pack;
MainLoop;

SEE ALSO

This module was written for Tk::ChoicesSet. There are others that offer more flexibility like:

JBrowseEntry
JComboBox
MatchEntry

AUTHOR

Christoph Lamprecht, ch.l.ngre@online.de

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Christoph Lamprecht

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 102:

Unknown directive: =over4

Around line 104:

'=item' outside of any '=over'