Hi all,
I'm teaching myself Objective-C and Cocoa, by working on a simple (so I
thought) modification to the default AudioUnit effect project. But in this
project, I create my own views programmatically instead of using the NIB. (I
know - why??? Just go with me, ok? :-))
I have a hierarchy of NSView descendants, and ones below a certain
"base" class in the hierarchy need to respond to mouse clicks. (Other branches
do not.)
My first attempt was to add -mouseUp: and -mouseDown: to the "base"
class that directly inherits from NSView, and then only override those in
subclasses that need changes to the default behavior. However, none of my
subclasses of that "base" class respond to mouse clicks when I do it that way.
In order to get the descendants of this base class to respond to mouse
clicks, I had to override those functions in *each* class that I want to handle
mouse clicks. (And in order to get the default behavior, I assume I'll just
call [super mouseDown:theEvent], right?)
I know I'm new at this, and maybe this is really an Objective-C
question, but.. why? What causes those functions to be called when implemented
in the individual subclasses, but not when only implemented in the base class?
Shouldn't all derived classes inherit the behavior of their ancestors,
including those functions?
I'm *guessing* that is has something to do with the way events are
handled, and that some kind of check is done to make sure the class
implementing those functions is in fact the same class as the target of the
event, but that's just a guess. My alternate guess is that's the way
Objective-C works.
Anyone care to enlighten me? I'm reading my little eyeballs out, but
just can't find much info on programatically-created NSView hierarchies (my
Cocoa programming book is all NIB-based stuff).
Thanks,
Howard
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]