Tk-HListbox
view release on metacpan or search on metacpan
Control-Left and Control-Right scroll the listbox view left and
right by the width of the window.
[8] The Prior and Next keys scroll the listbox view up and down by one
page (the height of the window).
Control-Prior and Control-Next scroll the listbox view up and down
by one page while selecting a page's worth of items.
[9] The Home and End keys scroll the listbox horizontally to the left
and right edges, respectively.
[10]
Control-Home sets the location cursor to the the first element in
the listbox, selects that element, and deselects everything else in
the listbox.
[11]
Control-End sets the location cursor to the the last element in the
listbox, selects that element, and deselects everything else in the
listbox.
[12]
In extended mode, Control-Shift-Home extends the selection to the
first element in the listbox and Control-Shift-End extends the
selection to the last element.
[13]
In multiple mode, Control-Shift-Home moves the location cursor to
the first element in the listbox and Control-Shift-End moves the
location cursor to the last element.
[14]
The space and Select keys toggle a selection at the location cursor
(active element) just as if mouse button 1 had been pressed over
this element.
[15]
In extended mode, Control-Shift-space and Shift-Select extend the
selection to the active element just as if button 1 had been pressed
with the Shift key down.
[16]
In extended mode, the Escape key cancels the most recent selection
and restores all the elements in the selected range to their
previous selection state. NOTE: This may not be fully working
correctly.
[17]
Control-slash selects everything in the widget, except in single and
browse modes, in which case it selects the active element and
deselects everything else.
[18]
Control-backslash deselects everything in the widget, except in
browse mode where it has no effect.
[19]
The F16 key (labelled Copy on many Sun workstations) or Meta-w
copies the selection in the widget to the clipboard, if there is a
selection.
[20]
We've added <Ctrl-<Prior>> and <Ctrl-<Next>> bindings to scroll the
listbox view up and down by one page while selecting a page's worth
of items.
The behavior of HListboxes can be changed by defining new bindings for
individual widgets or by redefining the class bindings.
TIED INTERFACE
The Tk::HListbox widget can also be tied to a scalar or array variable,
with different behaviour depending on the variable type, with the
following tie commands:
use Tk;
my ( @array, $scalar, $other );
my %options = ( ReturnType => "index" );
my $MW = MainWindow->new();
my $lbox = $MW->HListbox()->pack();
my @list = ( "a", "b", "c", "d", "e", "f" );
$lbox->insert('end', @list );
tie @array, "Tk::HListbox", $lbox
tie $scalar, "Tk::HListbox", $lbox;
tie $other, "Tk::HListbox", $lbox, %options;
currently only one modifier is implemented, a 3 way flag for tied
scalars "ReturnType" which can have values "element", "index" or "both".
The default is "element".
Tied Arrays
If you tie an array to the HListbox you can manipulate the items
currently contained by the box in the same manner as a normal array,
e.g.
print @array;
push(@array, @list);
my $popped = pop(@array);
my $shifted = shift(@array);
unshift(@array, @list);
delete $array[$index];
print $string if exists $array[$i];
@array = ();
splice @array, $offset, $length, @list
The delete function is implemented slightly differently from the
standard array implementation. Instead of setting the element at
that index to undef it instead physically removes it from the
HListbox. This has the effect of changing the array indices, so for
instance if you had a list on non-continuous indices you wish to
remove from the HListbox you should reverse sort the list and then
apply the delete function, e.g.
my @list = ( 1, 2, 4, 12, 20 );
my @remove = reverse sort { $a <=> $b } @list;
delete @array[@remove];
( run in 1.885 second using v1.01-cache-2.11-cpan-84e82930d8c )