-1

The following code creates a menu list called "User Selection" with four menu items: "Save", "Save As", "Load, and "Load From":

my $userselectedmenuitems = [
                      [ 'command' , 'Save', -command => \&saveUserSelection ]
                      [ 'command' , 'Save As', -command => \&saveUserSelectionAs ]
                      [ 'command' , 'Load', -command => \&loadSelectionsFromDefaultXMLFile ]
                      [ 'command' , 'Load From', -command => \&loadSelectionsFromUserSpecifiedXMLFile ] ;
my $userselectedmenu = $menubar->cascade (
                             -label => 'User Selection',
                             -tearoff => 0,
                             -menuitems => $userselectedmenuitems,
                      ) ;

Now, the following code will cause the entire menu list to be disabled:

$userselectedmenu->configure(-state => 'disable');

However, that's not what I want. I want to disable only one entry in the list (specifically the "Save" entry). How do I do that?

I saw online that many examples refer to the function "entryconfigure". However, when I run this code:

$userselectedmenu->entryconfigure('Save', -state => 'disable');

I get the following error message:

Can't locate object method "entryconfigure" via package "Tk::Menu::Cascade" at [line number]

Disclaimer: I apologize if this code needs some massaging to be reproducible, I have to transcribe code to this computer by hand.

1 Answer 1

2

You first need entrycget to get the menu, then you can use entryconfigure to disable its item:

$menubar->entrycget('User Selection', '-menu')
        ->entryconfigure('Save', -state => 'disabled');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.