-selectmode => 'multiple' only allows for contiguous selection, via click&drag or click&shift-click.

-selectmode => 'extended' allows for all that, plus non-contiguous selection, via ctrl-click.

Here is an example that will demonstrate the differences:

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::HList; my $mw = MainWindow->new(); my $hlist = $mw->HList( -itemtype => 'text', # -selectmode => 'multiple', -selectmode => 'extended', -browsecmd => \&bc, ); my $text = $mw->Text(); my @words = qw( aback abaft abandon babble babies baboon cabal cabana cabaret ); $hlist->add($_, -text=>$_) foreach qw(a b c); foreach ( @words ) { my $first = substr($_, 0, 1); $hlist->add("$first.$_", -text=>$_); } $hlist->pack(-side => 'top', -fill => 'both', -expand => 1); $text ->pack(-side => 'bottom', -fill => 'both', -expand => 1); MainLoop; sub bc { my $sel = join "\n", $hlist->infoSelection(); $text->delete('1.0', 'end'); $text->insert('end', $sel); }


In reply to Re: multiple selection in a Perl/Tk HList by Util
in thread multiple selection in a Perl/Tk HList by Real Perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.