Hi David,

Here is my sample code.  As you can see the 2 buttons are hidden and
executed by pressing "Enter" key.  The problem is the button1 is always
being executed by pressing the "enter" key and displays the message1. It
only works, if I have two button being visible and executed by clicking.

Is a way that I still can create 2 buttons being hidden  and executed by
pressing "Enter" key and behave the same as being visible and executed by
clicking?.

Thanks

Khoa Doan.          


#!/usr/bin/perl

use Win32::GUI;

$MW = new Win32::GUI::DialogBox(
   -title => 'test',  
   -left => 300,
   -top  => 200,
   -width => 350,
   -height => 350,
   -name => 'MainWindow',
);

$Label1 = $MW->AddLabel(
   -left => 10,
   -top  => 10,
   -text => 'Enter a word in Text Field 1:',
);

$TextField1 = $MW->AddTextfield(
   -name => 'Textfield1',
   -left => 150,
   -top  => 10,
   -width => 100,
   -height => 20,
);

$Button1 = $MW->AddButton(
   -name => 'Button1',
   -left => 260,
   -top  => 10,
   -text => 'button1',
   -tabstop => 1,
   -default => 1,
   -ok      => 1,
   -visible => 0,
);

$Message1 = $MW->AddLabel(
   -text => "",
   -top  => 100,
   -left => 60,
   -width => 200,
   -height => 40,
);

$Label2 = $MW->AddLabel(
  -left => 10,
  -top  => 50,
  -text => 'Enter a word in Text Field 2:',
);

$TextField2 = $MW->AddTextfield(
   -name => 'Textfield2',
   -left => 150,
   -top => 50,
   -width => 100,
   -height => 20,
);

$Button2 = $MW->AddButton(
   -name => 'Button2',
   -text => "Button2",
   -left => 260,
   -top  => 50,
   -tabstop => 1,
   -default => 1,
   -ok      => 1,
   -visible => 0,
);

$Message2 = $MW->AddLabel(
   -text => "",
   -top  => 200,
   -left => 60,
   -width => 200,
   -height => 40,
);

$MW->Show();
$TextField1->SetFocus();

Win32::GUI::Dialog();

sub MainWindow_Terminate {
   return -1;
}

sub Button1_Click {
   $value1 = $TextField1->Caption;
   $Message1->Text("$value1");
   $TextField2->Text("");
   $TextField2->SetFocus();
}

sub Button2_Click {
   $value2 = $TextField2->Caption;
   $Message2->Text("$value2");
   $TextField1->Text("");
   $TextField1->SetFocus();
}








                -----Original Message-----
                From:   David Hiltz [mailto:[EMAIL PROTECTED]]
                Sent:   Monday, January 24, 2000 4:24 PM
                To:     [EMAIL PROTECTED]
                Subject:        Re: [perl-win32-gui] Event button for
textfield

                > I have a window with two textfields, how do I create two
event buttons and
                > each event button will be assigned to each textfield
only?.

                  Do you have sample code?


Reply via email to