Re: Adding an event handler to an NSView subclass using categories
Re: Adding an event handler to an NSView subclass using categories
- Subject: Re: Adding an event handler to an NSView subclass using categories
- From: Yann Bizeul <email@hidden>
- Date: Sun, 6 May 2007 14:26:42 +0200
After a look at the documentation on categories, I noticed that :
"When a category overrides an inherited method, the new version can,
as usual, incorporate the inherited version through a message to
super. But there’s no way for a category method to incorporate a
method with the same name defined for the same class."
Well, english is not my spoken language, so fix me if I'm wrong, but
that means to me that :
A category should not implement a method declared in the class it
extends
A category could implement a method *inherited* from super
So if graphView does implement menuForEvent: then you can't override
it in your category and you'll have to subclass.
Anyone to confirm this ?
Yann Bizeul - yann at tynsoe.org
Cocoa Developer
Tynsoe Projects
BuddyPop - GeekTool - SSH Tunnel Manager - ...
http://projects.tynsoe.org/
Le 4 mai 07 à 16:54, Arthur C. a écrit :
Hello,
I make use of a graph-view class (which is a subclass of NSView) to
display graphs.
I want to add some features to be called from a contextual menu,
i.e. when someone does a control-click on the graph, a menu pops up
and some methods can be called.
As it is a third-party class with no source code, I have added a
'category' which has a method
- (NSMenu *) menuForEvent: (NSEvent *) theEvent;
This works fine - well, about half of the times. Sometimes the
control-click does give the menu, sometimes not. After
experimenting quite a bit, there's still no pattern telling when it
will or won't work...
So my question is whether this approach is valid? Or do I need to
subclass the graphView class?
Does it have something to do with the existing graphView code (to
which I have no access)?
Thanks in advance,
Arthur C.
_________________________________________________________________
Talk with your online friends with Messenger http://
www.join.msn.com/messenger/overview
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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