Re: Hiding contextual menu items

Christiaan Hofman <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Mar 8, 2010, at 17:18, David Dunham wrote:

> On 8 Mar 2010, at 08:00, Christiaan Hofman wrote:
> 
>> I have an NSTableView with a contextual menu, that's automatically updated using the -menuNeedsUpdate: delegate method. I want to conditionally hide some items, depending on the current state. So I tried to call -setHidden on the items on the menu in my implementation of -menuNeedsUpdate:. This does not work, the menu items are all shown, no matter whether I pass YES or NO to this method. What's going on, why doesn't it respect my settings? And is there an alternative way to do this?
> 
> 
> I think this is where I override menuForEvent and provide a menu with only the right items.
> 

Overriding menuForEvent is buggy in 10.5, as explained on the 10.6 release notes.

> Also, I think that if you're talking about standard items, you should disable them rather than hide, and that the hiding happens automatically.

I disagree that one should disable them for the case of a contextual menu, I would agree for most other types of menus. And hiding most definitely does not happen automatically, it does not even happen when explicitly done (as I was saying.)

Christiaan

> 
> David Dunham     A Sharp, LLC
> Voice/Fax: 206 783 7404     http://a-sharp.com
> Efficiency is intelligent laziness.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.