Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageIn article <1096269519.7634.10.camel@mail0.westernmidrange.com>, rduz-ptk@th
eduz.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.
Post Follow-up to this messageRich 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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.