Injecting an NSResponder into the responder chain
Injecting an NSResponder into the responder chain
- Subject: Injecting an NSResponder into the responder chain
- From: Glen Low <email@hidden>
- Date: Fri, 30 Apr 2004 17:01:23 +0800
Dear All,
I want to handle the changeFont: message from NSFontPanel, or a custom
message set using setAction:.
Now I do not use any custom NSView objects (or those that are custom
don't want to bother with handling changeFont:) in the hierarchies,
which really leaves three alternatives for catching this message:
1. My NSDocument subclass.
2. The main NSWindow delegate.
3. A custom NSResponder injected into the responder chain.
I don't like #1, since that means my NSDocument subclass needs to know
about selected properties, what an NSFont is, etc... a bit too much of
a MVC violation. (although if #3 proves to be tricky, I will go with
this.)
I don't like #2, since this would handle the message at a very general
level, and the delegate might want to do other things, whereas I just
wanted a single, small object that handles the message and not much
else.
Conceptually I tend to think, sending an object x a "changeFont:"
message really does mean "change object x's font", so I can't see this
applying to the NSDocument subclass or the NSWindow delegate (which is
sort of like the window itself).
#3 seems to be it, but...
A. The Cocoa docs talk about "injecting it into the responder chain" --
how do I do this, and successfully remove it from the chain when I'm
done?
B. What happens after I inject it into the chain, and the user clicks
on some other NSTextView and my responder is no longer in the chain?
It would be far simpler if NSFontPanel actually allows you to set the
target, unlike NSColorPanel...
Cheers, Glen Low
---
pixelglow software | simply brilliant stuff
www.pixelglow.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.