Thanks for that quick reply but I have two more problems and another question.
I ran your example and found that the cursor worked as I wanted.
However, I could only see what I had typed in the cell after I moved to another cell (as I used the cursor the cell 'flashed' and went white background).
I would like to see what is being typed.
I added '-browsecommand => \&brscmd,' to the options and copied the brscmd code (see below) However, I could only get output from the sub when I used the button twice but data did get typed in to the correct cell and I can saw what is begin typed.
How do I change things so that just one button hit selects the cell?
One other thing has just occurred to me. Is there an option I can set so that when the cell highlighted the Delete key will removed the cell's contents?
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::TableMatrix; use Tk::TableMatrix::Spreadsheet; use File::Basename; my ($mw, $arrayvar1, $arrayvar2, $rows1, $cols1, $rows2, $cols2, $tm1, + $tm2, $label, $jh1, $jh2, $rc_str); my (%hd1, %hd2, $pad_x, $pad_y, $wg_row); my (@sym_avail, %sym_att_data); $mw = MainWindow->new; $label = $mw->Label(-text => "Table Matrix Cell Input Test with Browse + Command") ->grid( -row => 0, -column => 0, -columnspan => 6); # set wg_row for widgets $wg_row = 1; # set x and y pads $pad_x = 3; $pad_y = 3; $wg_row += 1; $mw->Button( -text => "Print Selected Rows", -command => sub{&from_use_list})->grid(-row => 4, -column => 1, +-rowspan => 1, -padx => $pad_x, -pady => $pad_y); # list $arrayvar2 = {}; $hd2{0}{text} = 'Part'; $hd2{1}{text} = 'X size'; $hd2{2}{text} = 'Y Size'; $hd2{3}{text} = 'Material'; $hd2{4}{text} = 'Thickness'; $rows2 = 30; $cols2 = 5; for ($jh2 = 0; $jh2 < $cols2; $jh2 ++) { $rc_str = '0,' . $jh2; $arrayvar2->{$rc_str} = $hd2{$jh2}{text}; } print "Creating Table...\n"; #sub colSub{ # my $col = shift; # return "OddCol" if( $col > 0 && $col%2) ; #} $tm2 = $mw->Scrolled('Spreadsheet', -rows => $rows2, -cols => $cols2, -width => 6, -colwidth => 20, -height => 20, -titlerows => 1, -titlecols => 1, -variable => $arrayvar2, -browsecommand => \&brscmd, -colstretchmode => 'last', -flashmode => 1, -flashtime => 2, -wrap=>1, -rowstretchmode => 'last', -selectmode => 'extended', -selecttype=>'cell', -selecttitles => 1, -drawmode => 'slow', -scrollbars=>'se', -sparsearray=>0 )->grid(-row => $wg_row, -column => 0, -rowspan => 10, + -padx => $pad_x, -pady => $pad_y); $wg_row = 15; $mw->Button( -text => "Exit", -command => sub{$mw->destroy})->grid(-row => $wg_row, -column => + 0, -rowspan => 1); #==================================== # # get_selections_from_tm # # this gets the seleect rows from the given tablematrix # #==================================== sub get_selected_rows_from_tm ($$$) { my ($tm, $ref_rows, $ref_rows_total) = @_; my ($sel, $js, @js_split); $sel = $tm->curselection(); foreach $js (@$sel) { # print "$js\n"; @js_split = split(/,/, $js); $ref_rows->{$js_split[0]} = 1; } $$ref_rows_total = scalar(keys %$ref_rows); } #=========================== # # sub to_use_list # # this moves symbols from the given ($tm1) to used list ($tm2) # # button < # #=========================== sub from_use_list() { my (%rows2_sel, $rows2_sel_total, $js, $cell_str, $cell_sym, $row_min) +; get_selected_rows_from_tm ($tm2, \%rows2_sel, \$rows2_sel_total); print "\n[from_use_list] selected rows total <$rows2_sel_total>\n"; $row_min = 9999; foreach $js (sort{$a <=> $b} keys %rows2_sel) { if($js < $row_min) { $row_min = $js; } print "$js\n"; } } sub brscmd { my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; print "[brscmd] row $row col $col\n"; } Tk::MainLoop;

In reply to Re^2: Tk MatrixTable - entering data by merrymonk
in thread Tk MatrixTable - entering data by merrymonk

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.