Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Tk menu underline prob

by martymart (Deacon)
on May 19, 2003 at 17:06 UTC ( [id://259214]=perlquestion: print w/replies, xml ) Need Help??

martymart has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,

I'm using activestate perl on windows 2000, and I've just started to learn Tk, so apologies if this is an idiot question. I can't seem to make the underline work for the topmost item in the menu, in this case I get 'Menu' when I should be getting 'Menu'. Works fine for all the othe bits of the menu. I've included an example script below, but for the life of me I can't spot what I'm doing wrong. Is this just an issue with Tk on Windows platforms? or can I change the script below to get it working.

I'd appreciate your thought on this,
Martymart

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw=MainWindow->new; $mw->title('Menu Test'); my $menubar=$mw->Menu(-type=>'menubar'); $mw->configure(-menu=>$menubar); my $menu=$menubar->cascade(-label=>'~Menu'); my $menu_file=$menu->cascade(-label=>'~File', -tearoff=>0,); $menu_file->command( -label=>'~Open', -accelerator=>'Control+o', -command=>[\&print_it, 'Open']); $menu_file->command( -label=>'~Save', -accelerator=>'Control+s', -command=>[\&print_it, 'Save']); my $menu_edit=$menu->cascade(-label=>'~Edit'); $menu_edit->command( -label=>'C~ut', -accelerator=>'Control+x', -command=>[\&print_it, 'Cut']); $menu_edit->command( -label=>'~Copy', -accelerator=>'Control+c', -command=>[\&print_it, 'Copy']); my $exit=$mw->Button(-text=>'Exit', -command=>[$mw=>'destroy']); $mw->bind('<Control-o>',[\&print_it, 'Open']); $mw->bind('<Control-s>',[\&print_it, 'Save']); $mw->bind('<Control-x>',[\&print_it, 'Cut']); $mw->bind('<Control-c>',[\&print_it, 'Copy']); $exit->pack; MainLoop; sub print_it{ my $name=ref($_[0]) ? shift : ''; my $message=shift; print "message: '$message' ...\n"; }

Replies are listed 'Best First'.
Re: Tk menu underline prob
by Thelonius (Priest) on May 19, 2003 at 18:20 UTC
    The M will be underlined when you press Alt. That's the way menus are supposed to work on Windows.
      Thelonius is correct... However if you want to change this behavior on Win32 so that you don't have to press the ALT key to see short cut menus then all you have to do is:

      Display Properties->Appearance->Effects...->(uncheck)Hide underlined letters for keyboard navigation until I press the Alt key
      Cheers, JamesNC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://259214]
Approved by Thelonius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found