Re: Drag 'n Drop 'n Delegation Dilemma
Re: Drag 'n Drop 'n Delegation Dilemma
- Subject: Re: Drag 'n Drop 'n Delegation Dilemma
- From: Matt Neuburg <email@hidden>
- Date: Sun, 16 Jun 2002 08:41:13 -0700
On Sat, 15 Jun 2002 20:36:28 -0700, Demitri Muna <email@hidden> said:
>
I am trying to create an NSButton in my application that I can drop
>
certain items onto. I have done a lot of reading and found that
>
different people have recommended several ways to to this. One way is to
>
subclass NSButton and add implement the drag methods
>
(performDragOperation, etc.) there.
>
>
Is there a way (as I am led to believe) to do this that is preferable
>
through a delegate? How would this be done? I've tried to implement the
>
methods in my simple controller class, set an NSTextField's delegate to
>
that class, but the methods are not called. Is this the right approach,
>
or am I missing something big?
Delegation is not like subclassing; it's a completely different mechanism.
In subclassing, the subclass receives the same messages the superclass
would have received and can override them. In delegation, the delegate
receives a different set of messages - those that the appkit has predefined
to be sent to the delegate if there is one. If you look at the doc for a
class, the messages that its delegate receives are listed separately later
on that page; they are not the same as the messages that the class itself
receives. There are no delegate messages triggered in response to dragging.
It is not at all unreasonable to wish for a way to make the drag messages
get passed along to a delegate if there is one, so as not to have to
subclass. Objective-C messaging is so dynamic that there's probably a way
to do this, but I am too inexperienced to know what it is. m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.