discuss-gnustep
[Top][All Lists]
Advanced

[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: Wed, 15 Nov 2017 09:48:00 +0000

On 14 Nov 2017, at 21:19, Wolfgang Lux <wolfgang.lux@gmail.com> wrote:
> 
> So next time you probably should define your validateMenuItem: like this 
> (beware, untested code):
> 
> - (BOOL) validateMenuItem: (SEL)aSelector
> {
>  aSelector = NSSelectorFromString([NSStringFromSelector(aSelector) 
> stringByAppendingString: @"IsEnabled"]);
>  if ([self respondsToSelector: aSelector])
>    return (BOOL)[self performSelector: aSelector];
>  return YES;
> }

That’s not quite right, because you need to strip the trailing : from 
`NSStringFromSelector(aSelector)`.  It’s a bit annoying to do it here, because 
the NSMenuItem could cache the selector once per program invocation, rather 
than having to reconstruct it with string manipulation on each call.  Probably 
not a performance difference that’s noticeable to a human, but it seems 
inelegant.

Unfortunately, that’s what we’re stuck with if we want OpenStep / Cocoa compat.

David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]