I think having 'enter' press a button while another control has focus can
only happen in a dialog box. Try this:
use Win32::GUI;
my $dialogbox = new Win32::GUI::DialogBox(
-name => 'dialogbox',
-text => 'Demo Dialogbox',
-left => 300,
-top => 120,
-left => 120,
-width => 300,
-height => 150,
-minwidth => 300,
-minheight => 150,
-maxwidth => 300,
-maxheight => 150,
-helpbutton => 1,
-menu => 0,
-maximizebox => 0,
-minimizebox => 0,
-resizable => 0,
);
$dialogbox->Show();
my $text = $dialogbox->AddTextfield(
-name => 'text',
-text => 'some text',
-left => 10,
-top => 25,
-size => [150,25],
-tabstop => 1,
-prompt => 'enter something:',
);
$text->SendMessage(197, 10, 0); # limit to 10 character input
my $button = $dialogbox->AddButton(
-name => 'button',
-text => 'demo button',
-left => 25,
-top => 55,
-tabstop => 1,
-default => 1,
-ok => 1, # clicks this button when enter is presses, only works in a
DialogBox
);
$text->SetFocus();
Win32::GUI::Dialog;
sub button_Click
{
$tln = $text->Caption;
print "$tln\n";
}
sub dialogbox_Terminate {
$dialogbox->Disable();
$dialogbox->Hide();
return -1; # must return -1??
}
Nathaniel G. Bartusiak
TTMS, Keesler AFB
>
> Marc,
>
> You could give the button focus:
>
> $Win_info_srv->Button_ok_srv->SetFocus();
>
> would do that.
>
> To have "enter" press the button when another control had focus there
> needs to be a way of getting the window to call your button click
> routine when enter is pressed. So far I've only seen this with Tk
> windows but hopefully someone else knows how to do it with the GUI
> module.
>
> Kev.
>
>
>
> |---------+------------------------------------------------>
> | | "NAHUM Marc" |
> | | <[EMAIL PROTECTED]> |
> | | Sent by: |
> | | [EMAIL PROTECTED]|
> | | ceforge.net |
> | | |
> | | |
> | | 13/12/2002 09:46 |
> | | |
> |---------+------------------------------------------------>
>
> >----------------------------------------------------------------------------------------------|
> |
> | | To: "Win32-GUI Users"
> <[email protected]> | |
> cc:
> | | Subject: [perl-win32-gui-users] set button
> as default |
>
> >----------------------------------------------------------------------------------------------|
>
>
>
>
>
> how set a button as delault ?
>
> when I put somthing like this :
>
> $Win_info_srv->AddButton(
> -text => "OK",
> -name => "Button_ok_srv",
> -left => 190,
> -top => 185,
> -width => 50,
> -height => 21,
> -foreground => 0,
> -tabstop => 1,
> -default => 1,
> );
>
> the button is like default but I can't push "enter" to validate ....
>
> thanks for help ...
>
>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:
> With Great Power, Comes Great Responsibility
> Learn to use your power at OSDN's High Performance Computing Channel
> http://hpc.devchannel.org/
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users