Home > Archive > PerlTk > April 2004 > Optionmenu and keyboard focus question (code included)
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 |
Optionmenu and keyboard focus question (code included)
|
|
| psyshrike 2004-04-27, 3:07 pm |
| Howdy,
With the following example, I can traverse from one Optionmenu to the
next with Tab, but when a menu is pulled down with the spacebar the
keyboard focus emediately returns to whichever Optionmenu was first
selected with the keyboard.
For example, select an item from $OM1 with space, then tab to $OM2 and
select an option with space. Note the focus returns to $OM1.
How do I preserve the focus on the selected Optionmenu widget? I am
guessing this is a class vs. instance binding issue. I am sure
somebody must have fixed this before, but I wasn't able to find it in
the archives. Any suggestions?
-Thanks in advance
-Matt
########################## EXAMPLE ##########################
#!/usr/bin/perl -w
use Tk ;
use Tk::Optionmenu ;
my $MW = MainWindow->new() ;
my $F1 = $MW->Frame()->pack() ;
my $OM1 = $F1->Optionmenu(-options => ['N/A', 1, 2, 3, 4, 5],
-command => \&foo)->pack() ;
my $OM2 = $F1->Optionmenu(-options => ['N/A', 1, 2, 3, 4, 5],
-command => \&foo)->pack() ;
my $OM3 = $F1->Optionmenu(-options => ['N/A', 1, 2, 3, 4, 5],
-command => \&foo)->pack() ;
MainLoop ;
sub foo {
warn ("bar") ;
}
########################################
#######################
# using Activestate 5.6.1 & Tk 800.022 on Win32
#
| |
| Slaven Rezic 2004-04-27, 4:57 pm |
| shrike@cyberspace.org (psyshrike) writes:
> Howdy,
>
> With the following example, I can traverse from one Optionmenu to the
> next with Tab, but when a menu is pulled down with the spacebar the
> keyboard focus emediately returns to whichever Optionmenu was first
> selected with the keyboard.
>
> For example, select an item from $OM1 with space, then tab to $OM2 and
> select an option with space. Note the focus returns to $OM1.
I cannot reproduce this behaviour neither with Tk800.024 nor with
Tk804.027 on a Unix system. So it's either a Windows issue, or an
issue of your old Tk version.
Regards,
Slaven
>
> How do I preserve the focus on the selected Optionmenu widget? I am
> guessing this is a class vs. instance binding issue. I am sure
> somebody must have fixed this before, but I wasn't able to find it in
> the archives. Any suggestions?
>
> -Thanks in advance
> -Matt
>
> ########################## EXAMPLE ##########################
> #!/usr/bin/perl -w
>
> use Tk ;
> use Tk::Optionmenu ;
>
> my $MW = MainWindow->new() ;
> my $F1 = $MW->Frame()->pack() ;
>
> my $OM1 = $F1->Optionmenu(-options => ['N/A', 1, 2, 3, 4, 5],
> -command => \&foo)->pack() ;
>
>
> my $OM2 = $F1->Optionmenu(-options => ['N/A', 1, 2, 3, 4, 5],
> -command => \&foo)->pack() ;
>
> my $OM3 = $F1->Optionmenu(-options => ['N/A', 1, 2, 3, 4, 5],
> -command => \&foo)->pack() ;
>
> MainLoop ;
>
> sub foo {
> warn ("bar") ;
> }
>
> ########################################
#######################
> # using Activestate 5.6.1 & Tk 800.022 on Win32
> #
--
Slaven Rezic - slaven@rezic.de
Berlin Perl Mongers - http://berlin.pm.org
|
|
|
|
|