I'm interested in using two textfields in a DialogBox. Each textfield needs to except input from the enter key. I have learned that when you create your first button with -ok => 1, this becomes the button that will click regardless of the textbox you are in.

I'm including some code I'm playing around with:
When you run this and enter 1 for TextBox 1 and 2 for TextBox 2, Then click on FirstName Button - The result is Button 1 Clicked and a 1 on the next line. This is Expected. Then click on LastName Button - The result is Button 2 Clicked and a 2 on the next line. This is Expected. When you go into TextBox1 and click enter the result is "Button 1 Clicked" and a 1 on the next line. This is Expected. When you go into TextBox2 and click enter the result is This is NOT Expected.

How do I get the result "Button 2 Clicked" and a 2 on the next line, when I go into textbox2 and click ?
It seems the -ok => 1 only works for the first button created. Any suggestions. Thanks.
Dave
use Win32::GUI;
my $W1 = Win32::GUI::DialogBox->new(
-name => "W1",
-title => "First Window",
-pos => [ 100, 100 ],
-size => [ 300, 200 ], );

$W1->AddButton( -name => "ButtonW1",
-text => "FirstName",
-pos => [ 87, 100 ],
-ok => 1,

              );  
$W1->AddButton( -name => "ButtonW2",
-text => "LastName",
-pos => [ 87, 120 ],
-ok => 1,

              );     
# $W1->ButtonW1->Disable();
$W1->AddTextfield( -name => "tf1",
-left => 20,
-top => 40,
-width => 250,
-height => 20, -prompt => "1:",
);

$W1->AddTextfield(  -name     => "tf2",  
                    -left     =>  20,  
                    -top      =>  60,  
                    -width    => 250,  
                    -height   => 20,
                    -prompt   => "2:",                     
                ); 
$W1->Show(); print "This is a test\n"; Win32::GUI::Dialog(); exit(0);
sub W1_Terminate { return -1; }
sub ButtonW1_Click {
print "Button 1 Clicked\n"; my $text = $W1->tf1->Text();
print "$text\n"; }

sub ButtonW2_Click {
print "Button 2 Clicked\n"; my $text = $W1->tf2->Text();
print "$text\n"; }