Secrets

#!/usr/bin/perl -- # Tk-event-secrets.pl # # 2020-01-25-21:28:48 # # https://perlmonks.org/?node_id=11111879 # # #!/usr/bin/perl -- use strict; use warnings; use Tk; my $mw = new MainWindow; my $text = $mw->Scrolled( "Text", -scrollbars => 'e', )->pack( -side => 'bottom', -anchor => 'w', ); my $label = $mw->Label( -text => "hello" )->pack( -side => 'left', -anchor => 'n', ); my $entry = $mw->Entry()->pack( -side => 'left', -anchor => 'n', ); #~ $text->bind('<Key-Return>',\&verwijs); #~ $entry->bind('<Key-Return>',\&verwijs); $mw->bind( '<Key-Return>', \&verwijs ); $entry->focus; #~ $mw->WidgetDump; MainLoop; sub verwijs { printf "## %30s %s\n", '@_', "@_"; printf "## %30s %s\n", '$Tk::widget', $Tk::widget; printf "## %30s %s\n", 'Tk::event->W', $Tk::event->W; printf "## %30s %s\n", 'Tk::event', $Tk::event; printf "## %30s %s\n", '$mw->focusCurrent', $Tk::widget->toplevel->focusCurrent; printf "## %30s %s\n", $mw, $Tk::widget->toplevel; print "\n\n"; } __END__ $ perl Tk-event-secrets.pl ## @_ Tk::Entry=HASH(0x102ff2c) ## $Tk::widget Tk::Entry=HASH(0x102ff2c) ## Tk::event->W Tk::Entry=HASH(0x102ff2c) ## Tk::event XEvent=SCALAR(0x101099c) ## $mw->focusCurrent Tk::Entry=HASH(0x102ff2c) ## MainWindow=HASH(0xf3ad8c) MainWindow=HASH(0xf3ad8c) ## @_ Tk::Text=HASH(0xf20334) ## $Tk::widget Tk::Text=HASH(0xf20334) ## Tk::event->W Tk::Text=HASH(0xf20334) ## Tk::event XEvent=SCALAR(0x1010b9c) ## $mw->focusCurrent Tk::Text=HASH(0xf20334) ## MainWindow=HASH(0xf3ad8c) MainWindow=HASH(0xf3ad8c) ## @_ Tk::Scrollbar=HASH(0x10212d4) ## $Tk::widget Tk::Scrollbar=HASH(0x10212d4) ## Tk::event->W Tk::Scrollbar=HASH(0x10212d4) ## Tk::event XEvent=SCALAR(0x106d6e4) ## $mw->focusCurrent Tk::Scrollbar=HASH(0x10212d4) ## MainWindow=HASH(0xf3ad8c) MainWindow=HASH(0xf3ad8c)

In reply to Re^2: [Tk] use enter key iso command button Tk focus by Anonymous Monk
in thread [Tk] use enter key iso command button by Anonymous Monk

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.