Code Comments
Programming Forum and web based access to our favorite programming groups.Hi Folks
I've some question to the focus-method and bind.
see this little code:
$entry->bind("<KeyPress-Tab>",sub { check_entry();});
in the check_entry subroutine the entered value will be tested, and if
test fails the value will be cleared.
in this case I do the following:
$entry->focus();
the focus should be returned to the $entry-widget, but it doesnt't works
so.
Why ??
Thanks
Pit
Post Follow-up to this message
"Pit" <pharrendorf@am-soft.de> wrote in message
news:47e6855e20101a25fbbd1cb956d80837@lo
calhost.talkaboutprogramming.com...
> Hi Folks
>
> I've some question to the focus-method and bind.
>
> see this little code:
>
> $entry->bind("<KeyPress-Tab>",sub { check_entry();});
>
> in the check_entry subroutine the entered value will be tested, and if
> test fails the value will be cleared.
> in this case I do the following:
>
> $entry->focus();
>
> the focus should be returned to the $entry-widget, but it doesnt't works
> so.
>
> Why ??
Likely because the default binding for a tab on a MainWindow is to
"focusNext". i.e. that is how you move focus from widget to widget without
using the mouse. An easy bandaid fix is to either adjust your binding to a
KeyRelease-Tab (untested) or just delay your command with "after". The
latter will mean that the focus will shift to the next widget for a very
brief period before being reset to your entry.
sub validate_your_entry {
blah blah
$entry->after(75,sub{$entry->focus});
return 1;
}
Jack
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.