Home > Archive > PerlTk > September 2004 > Accelerators not working?
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 |
Accelerators not working?
|
|
| Rich Duzenbury 2004-09-27, 8:58 am |
| Hi,
I must be doing something silly - my menu accelerators don't seem to
function. I did some googling, but didn't come up with anything
concrete to try. I have fiddled with different options for the
accelerator key, to no avail.
Platform Linux, Redhat 9.
Tk 804.025
Perl 5.008
What I'm expecting in my application is that hitting control-N while
anywhere in the main window should invoke the 'File/New' routine in my
program. I can type Alt-f, N successfully, and I can click File->new
with the mouse successfully as well.
Here is the code I'm using to create the menu:
$mw->configure(-menu => my $menubar = $mw->Menu(-menuitems =>
&generate_menu, -tearoff => 0));
sub generate_menu {
[
map ['cascade', $_->[0], -menuitems => $_->[1], -tearoff => 0],
['~File',
[
[qw/command ~New -accelerator Ctrl-n -command/ =>
\&on_file_new],
[qw/command ~Print -accelerator Ctrl-p -command/ =>
\&on_file_print],
[qw/command E~xit -accelerator Ctrl-q -command/ =>
\&on_file_exit],
],
],
['~Edit',
[
[qw/command Cu~t -accelerator Ctrl-x -command/ =>
\&on_edit_cut],
[qw/command ~Copy -accelerator Ctrl-c -command/ =>
\&on_edit_copy],
[qw/command ~Paste -accelerator Ctrl-v -command/ =>
\&on_edit_paste],
[qw/command P~references -accelerator Ctrl-r -command/
=> \&on_edit_preferences],
],
],
['~Help',
[
[qw/command ~About -command/ => \&on_help_about],
],
],
]
}
Thanks for any help you can offer.
--
Regards,
Rich
Current Conditions in Des Moines, IA
Broken Clouds
Temp 57.2F
Winds out of the Southwest at 3mph
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
| |
| Marc Dashevsky 2004-09-27, 4:01 pm |
| In article <1096269519.7634.10.camel@mail0.westernmidrange.com>, rduz-ptk@theduz.com
says...
>
> I must be doing something silly - my menu accelerators don't seem to
> function.
Sadly, I have observed that the -accelerator option functions
only to display the appropiate key sequence in the menu item.
One must still explicity bind this sequence to the command.
> I did some googling, but didn't come up with anything
> concrete to try. I have fiddled with different options for the
> accelerator key, to no avail.
>
> Platform Linux, Redhat 9.
> Tk 804.025
> Perl 5.008
>
> What I'm expecting in my application is that hitting control-N while
> anywhere in the main window should invoke the 'File/New' routine in my
> program. I can type Alt-f, N successfully, and I can click File->new
> with the mouse successfully as well.
>
> Here is the code I'm using to create the menu:
>
> $mw->configure(-menu => my $menubar = $mw->Menu(-menuitems =>
> &generate_menu, -tearoff => 0));
>
> sub generate_menu {
> [
> map ['cascade', $_->[0], -menuitems => $_->[1], -tearoff => 0],
>
> ['~File',
> [
> [qw/command ~New -accelerator Ctrl-n -command/ =>
> \&on_file_new],
> [qw/command ~Print -accelerator Ctrl-p -command/ =>
> \&on_file_print],
> [qw/command E~xit -accelerator Ctrl-q -command/ =>
> \&on_file_exit],
> ],
> ],
> ['~Edit',
> [
> [qw/command Cu~t -accelerator Ctrl-x -command/ =>
> \&on_edit_cut],
> [qw/command ~Copy -accelerator Ctrl-c -command/ =>
> \&on_edit_copy],
> [qw/command ~Paste -accelerator Ctrl-v -command/ =>
> \&on_edit_paste],
> [qw/command P~references -accelerator Ctrl-r -command/
> => \&on_edit_preferences],
> ],
> ],
> ['~Help',
> [
> [qw/command ~About -command/ => \&on_help_about],
> ],
> ],
> ]
> }
>
> Thanks for any help you can offer.
> --
> Regards,
> Rich
>
> Current Conditions in Des Moines, IA
> Broken Clouds
> Temp 57.2F
> Winds out of the Southwest at 3mph
>
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> This message was posted through the Stanford campus mailing list
> server. If you wish to unsubscribe from this mailing list, send the
> message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
>
--
Go to http://MarcDashevsky.com to send me e-mail.
| |
| Nick Ing-Simmons 2004-09-30, 8:57 pm |
| Rich Duzenbury <rduz-ptk@theduz.com> writes:
>On Mon, 2004-09-27 at 11:25, Arms, Mike wrote:
>Doh! As soon as I read this in MPTK, I skipped the whole section and
>went straight for the ' ' menus. I thought that specifying the
>accelerator would actually *do* something.
To be honest I don't blame you.
It probably should.
The snag is all the Alt/Meta/Shift/Control short hand in accelerators
is/was rather platform specific.
>--
>Regards,
>Rich
>
>Current Conditions in Des Moines, IA
>Overcast
>Temp 71.6F
>
>-++**==--++**==--++**==--++**==--++**==--++**==--++**==
>This message was posted through the Stanford campus mailing list
>server. If you wish to unsubscribe from this mailing list, send the
>message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
|
|
|
|
|