In Tk::Table and Tk::TableMatrix there is no click event.

Example of Tk::TableMatrix in "list mode". The user can click a row and the program responds with a message in the console."

use strict; use warnings; use Tk; use Tk::TableMatrix; my $main = MainWindow->new; $main->title("TM - in list mode"); my $xtvar; foreach my $row (0 .. 7){ foreach my $col (0 .. 2){ if ($col == 0) { $xtvar->{"$row,$col"} = "click row $row"; } else { $xtvar->{"$row,$col"} = "r$row, c$col"; } } } my $xtable = $main->Scrolled( 'TableMatrix', -rows => 8, -cols => 3, -ipadx => 3, -variable => $xtvar, -selectmode => 'single', -selecttype => 'row', -resizeborders => 'none', -state => 'disabled', -cursor => 'top_left_arrow', -bg => 'white', -scrollbars => 'ose', )->pack; # Clean up if mouse leaves the widget $xtable->bind( '<FocusOut>', sub { my $w = shift; $w->selectionClear('all'); } ); # Highlight the cell under the mouse $xtable->bind( '<Motion>', sub { my $w = shift; my $Ev = $w->XEvent; if ( $w->selectionIncludes( '@' . $Ev->x . "," . $Ev->y ) ) { Tk->break; } $w->selectionClear('all'); $w->selectionSet( '@' . $Ev->x . "," . $Ev->y ); Tk->break; } ); # MouseButton 1 event $xtable->bind( '<1>', sub { my $w = shift; $w->focus; my ($rc) = @{ $w->curselection }; # Do something with the selection print " Selection: $rc\n"; } ); MainLoop;

In reply to Re^3: Perl Tk : show list box items in grid style by stefbv
in thread Perl Tk : show list box items in grid style by selva

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.