>
> my $Text = $W->AddTextfield(
> -name => 'TextField',
> -text => 'example',
> -top => 10,
> -left => 10,
> -width => 480,
> -height => 300,
> -multiline => 1,
> -tabstop => 1,
> );
The problem here seems to be with -multiline, because if you comment that
out it works. Probably best to use a RichEdit.
>
> my $Button = $W->AddButton(
> -name => 'But',
> -text => 'ok',
> -left => 200,
> -top => 400,
> -width => 100,
> -height => 25,
> -tabstop => 1,
> );
>
> $W->Show;
> $W->Dialog;
>
>
> sub Textfield_KeyPress {
> my($key) = @_;
>
> if($key == 9) {
> $W->But->SetFocus();
> }
> }
>
This method is meant for RichEdit objects. I don't think it works with
textfields. THe below seems to do what you want, although it is not showing
the text in the RichEdit field, although it is getting the keypresses. I
forget what I did with this in the past -- maybe captured the keys, joined
them something like this?
sub Editor_KeyPress {
my($key) = @_;
push(@keystrokes,$key);
$W->Editor->Text(@keystrokes);
???
### SCRIPT
use strict;
use Win32::GUI;
my $W = new Win32::GUI::Window(
-name => 'Window',
-text => 'Testing',
-top => 100,
-left => 100,
-width => 500,
-height => 500,
);
$W->{-dialogui} = 1;
my $EditorClass = new Win32::GUI::Class(
-name => "Editor",
-extends => "RichEdit",
-widget => "RichEdit",
);
my $WindowEditor = $W->AddRichEdit(
-class => $EditorClass,
-name => "Editor",
-pos => [ 0, 200 ],
-multiline => 1,
-left => 10,
-top => 10,
-width => 480,
-height => 300,
-exstyle => WS_EX_CLIENTEDGE,
-style => WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL
| ES_LEFT | ES_MULTILINE,
-tabstop => 1,
);
my $Button = $W->AddButton(
-name => 'But',
-text => 'ok',
-left => 200,
-top => 400,
-width => 100,
-height => 25,
-tabstop => 1,
-ok => 1,
);
$W->Show;
$W->Editor->SetFocus();
$W->Dialog;
sub Editor_KeyPress {
my($key) = @_;
print "Just got character $key\n";
if($key == 9) {
print "Just got a tab!\n";
$W->But->SetFocus();
}
}
sub But_Click
{
print "Button was clicked.\n";
$W->Editor->SetFocus();
}
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs