Dear All, I have created Labels and Entry widget in loop ,but when i tried to implement enter key event like if press entry key then focus should go to next entry widget not other widget,Please correct my code. ------------
#!/usr/bin/perl use Tk; use Tk::Entry; use Tk::Table; use Tk::LabFrame; use warnings; use strict; my $v="0.00"; my $mw = MainWindow->new; $mw->geometry("200x200"); $mw->resizable(0,0); $mw->title("Table Example"); my @id=qw/100 101 102 103 104 105 106 107 108 109 110/; my @name=qw/AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK/; my @top2=qw/No Name Amount/; my $table_frame = $mw->LabFrame()->pack(); my $table = $table_frame->Table(-columns => 10, -rows => 6, -fixedrows + => 1, -scrollbars => 'oe', -relief => 'raised',-background=>'white'); my $j=0; my $i=0; foreach my $j(1..11) { my $tmp_label=$table->Label(-text => $id[$i], -width => 8, -relief =>' +raised'); my $tmp_label1 = $table->Label(-text => $name[$i], -width => 8, -relie +f =>'raised'); my $tmp_label2= $table->Entry( -width => 8, -relief =>'raised',-valida +te=>'key',-validatecommand=>sub{$_[1]=~m/[\d\d]/} ,-invalidcommand=>sub{$mw->bell} ); $tmp_label2->bind('Tk::Entry','<Return>',sub{shift->focusNext}); $table->put($j,1,$tmp_label); $table->put($j,2,$tmp_label1); $table->put($j,3,$tmp_label2); $i++; } $table->pack(); my $button_frame = $mw->Frame( -borderwidth => 4 )->pack(); $button_frame->Button(-text => "Exit", -command => sub {exit})->pack() +; #$button_frame->Button(-t)->pack(); MainLoop;

In reply to Enter Key focus is not happening by gocpon

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.