Tk::MatchingBE - A single-selection BrowseEntry with 'matching' Entry widget |
Tk::MatchingBE - A single-selection BrowseEntry with 'matching' Entry widget
require Tk::MatchingBE;
$mw->MatchingBE(-choices => [qw/foo bar baz/])->pack;
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.
Tk::MatchingBE supports the following methods:
Tk::MatchingBE supports the following options:
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;
This module was written for Tk::ChoicesSet. There are others that offer more flexibility like:
Christoph Lamprecht, ch.l.ngre@online.de
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.
Tk::MatchingBE - A single-selection BrowseEntry with 'matching' Entry widget |