discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMenu fix


From: Wolfgang Lux
Subject: Re: NSMenu fix
Date: Thu, 23 Oct 2008 19:24:00 +0200

Fred Kiefer wrote:

Wolfgang Lux wrote:
The following patch fixes NSMenu's -indexOfItemWithTarget:andAction:
method so that it becomes possible to look up items with a nil target,
i.e., which send their action to the first responder.

[...]
I would like to hear some more opinions on those choices before deciding
what to do. Perhaps somebody could check on Apple what they are doing?

I think the best is to follow the specification from the NSMenu class,
which reads:

- (int)indexOfItemWithTarget:(id)anObject andAction:(SEL) actionSelector
  Parameters
   anObject
    An object that is set as the target of a menu item of the receiver.
   actionSelector
    A selector identifying an action method. If actionSelector is NULL,
    the first menu item in the receiver that has target anObject is
    returned
  Return Value
The integer index of the menu item or, if no such menu item is in the
    menu, –1.

In my understanding, this implies that the use of isEqual: in method
indexOfItemWithTarget:andAction: was wrong in the first place and the
inner conditional should simply read
  if ([menuItem target] == anObject) ...
I have updated the patch accordingly.

Wolfgang

Attachment: menu2.patch
Description: Binary data




reply via email to

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