I don't think you can use the Win32::GUI::AcceleratorTable for a widget ( I couldn't get tit to work for the Textfield anyway ). But here is some code that does what you are looking for. At least I think it does. You should really post more code to show the situation you are dealing as well as tell us what you have tried so far. Anyway, here's some code that gives an example of at least one way to do it:
#!c:\perl\wperl.exe -w use strict; use warnings; use Win32::GUI; my $t_font = Win32::GUI::Font->new( -name => "Arial", -size => 7 ); my $accelerators = new Win32::GUI::AcceleratorTable("Return" => "Enter +"); my $main = Win32::GUI::Window->new(-name=>'main',-text=>'test',-width= +>200,-height=>200,-dialogui=>1,-accel=>$accelerators); my $button1 = $main->AddButton(-name=>'button1',-top=>10,-left=>10,-te +xt=>"button1",-ok=>0); my $lotid = $main->AddTextfield( -name => "lotid", -keepselection => 1, -top => 30, -left => 10, -width => 125, -height => 20, -font => $t_font, -readonly => 0, ); my $lotid_hwnd = $main->lotid->{-handle}; #print "Handle of the lotid textfield: $lotid_hwnd\n"; $main->Show(); Win32::GUI::Dialog(); exit; sub Enter_Click { my $control_hwnd = $main->GetFocus(); #print "handle of the control with the focus: $control_hwnd\n"; if($control_hwnd == $lotid_hwnd) { $main->MessageBox("You pressed Return in while in the textfiel +d. This is what was int he textfield: \"" . $lotid->Text() . "\"","En +ter_Click"); button1_Click(); } else { $main->MessageBox("You pressed Return in while NOT in the text +field.","Enter_Click"); } return 1; } sub button1_Click { $main->MessageBox("You clicked button1.","button1"); } sub main_Termintate { $main->Hide(); return -1; }

In reply to Re^3: Win32::GUI Issues by ChrisR
in thread Win32::GUI Issues by anselmomh

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.