Re: Sometimes all my menus are disabled
Re: Sometimes all my menus are disabled
- Subject: Re: Sometimes all my menus are disabled
- From: Graham Cox <email@hidden>
- Date: Mon, 13 Feb 2017 09:40:00 +1100
Another possibility is that the target (app delegate) overrides -validateMenuItem: and isn’t doing the right thing.
—Graham
> On 13 Feb 2017, at 7:55 AM, Kyle Sluder <email@hidden> wrote:
>
>>>
>>> On Feb 12, 2017, at 12:36 PM, Andreas Falkenhahn <email@hidden> wrote:
>>
>>
>>> On 12.02.2017 at 21:29 Kyle Sluder wrote:
>>>
>>> You’ve wired up every single menu item to a single action in your app
>>> delegate? That’s certainly non-standard.
>>
>> It's really old code. It's an Xcode project I originally created on a
>> PowerPC Mac some 10 years ago, so I don't really remember how I used
>> Interface Builder back then. All I see is that every single menu item
>> has an entry under "Sent Actions" that links to "AppDelegate: menuClick".
>> The menu events are then processed in the "menuClick" method of my
>> app delegate.
>>
>>> By default, menus automatically enable/disable their items based on
>>> whether the target can perform the action. Perhaps your app delegate is
>>> being deallocated, and thus the menu is walking the responder chain and
>>> failing to find a responder that responds to -menuClick:?
>>
>> But how can that possibly happen? I'm certainly not deallocating the
>> app delegate myself...
>
> There are plenty of ways to write refcounting bugs. But the refcounting bug is just a theory. All we know for sure is that something is disabling the menu items. I assume you have not turned off the default autoenablesItems property on the menu, so that leaves a few possibilities:
>
> 1. The target of your menu items is being replaced with an object that does not respond to -menuClick:.
> 2. The target of your menu items is being deallocated, and a new object is being allocated in its place that does not respond to -menuClick:.
> 3. The target of your menu items is being deallocated, and NSMenuItem’s weak target pointer is being nilled out (special case of #1).
> 4. The menu has a delegate, and it implements of one of the menu update callbacks to disable the menu items.
> 5. Some arbitrary object in your app is grabbing a reference to the menu items and disabling them.
>
> --Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden