[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: issue with auto-enable of Menus
From: |
David Chisnall |
Subject: |
Re: issue with auto-enable of Menus |
Date: |
Mon, 13 Nov 2017 18:13:24 +0000 |
On 13 Nov 2017, at 17:52, Wolfgang Lux <wolfgang.lux@gmail.com> wrote:
>
>> Would it make sense to not have custom code to enable/disable menu items,
>> and just have appkit do it for you depending on the target?
>
> In my experience, custom code is unavoidable in almost any non-trivial case
> because the AppKit is not able to determine exactly when a menu item is
> applicable and when not. Having support for the selectors is a necessary but
> not a sufficient condition.
IOKit improves this relative to AppKit by adding the delegates to the responder
chain. For custom views, I’ve taken to doing this and forwarding some of the
responder chain queries to the delegate. It would also be nice if there were
some convention such as {selector}IsEnabled, so if you implement -paste: and
-pasteIsEnabled then you can turn off paste by returning NO to -pasteIsEnabled.
David