Home > Archive > PerlTk > September 2004 > A question to focus-method and bind
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
A question to focus-method and bind
|
|
|
| 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
| |
| Jack D 2004-09-24, 3:57 am |
|
"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
|
|
|
|
|