I know this was asked before, but I can't find the article anymore.
How do you delete entries in a Text's popup menu? Not just the toplevel
entries (like File, Edit etc), but cascade entries as well.
I want to remove the 'File->Exit' entry without removing the whole 'File' menu.
Any ideas?
MB
Searching google groups will likely turn up something :)
>
> How do you delete entries in a Text's popup menu? Not just the toplevel
> entries (like File, Edit etc), but cascade entries as well.
>
> I want to remove the 'File->Exit' entry without removing the whole 'File'
menu.
>
> Any ideas?
# Example of manipulating the text menu popup.
use Tk;
use strict;
my $mw=tkinit;
my $text=$mw->Text->pack;
my $textmenu=$text->menu;
#get the menu associated with 'File'
my $filemenu=$textmenu->entrycget('File',-menu);
#Delete the 'Exit' command
$filemenu->delete(0);
#Replace it with your own
$filemenu->insert(0,'command',-label=>'Press Me', -command=>sub{print "I was
pressed\n"});
#Get the menu associated with 'Edit'
my $editmenu=$textmenu->entrycget('Edit',-menu);
#Delete the 'Cut' command
$editmenu->delete('Cut');
MainLoop;
Jack
MB