Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Accelerators not working?
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

Report this thread to moderator Post Follow-up to this message
Old Post
Rich Duzenbury
09-27-04 01:58 PM


Re: Accelerators not working?
In 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Marc Dashevsky
09-27-04 09:01 PM


RE: Accelerators not working?
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

Report this thread to moderator Post Follow-up to this message
Old Post
Nick Ing-Simmons
10-01-04 01:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:30 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.