Using validateUserInterfaceItem it is possible to disable/enable a menu item but I need a similar behaviour to hide menu items, have you some hints?
Using validateUserInterfaceItem it is possible to disable/enable a menu item but I need a
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
– (BOOL)validateMenuItem:(NSMenuItem *)menuItem
Some details in the docs.
Update:
NSMenus do not hide NSMenuItems if
validateMenuItem:returnsNO. The according NSMenuItem gets disabled (Which tells the user that the functionality is there, but currently not applicable).This behavior is also suggested in Apple’s HIG. (See the second paragraph in the “Naming Menu Items” section)
Two other notes about NSMenuItem’s
enabledstate:setEnabledonly works ifautoenablesItems:of the hosting NSMenu is set toYESvalidateMenuItem:seems to traverse the responder chain to check if the target/action of a NSMenuItem is available.