Re: saveDocument:
Re: saveDocument:
- Subject: Re: saveDocument:
- From: ecir hana <email@hidden>
- Date: Wed, 09 May 2012 11:45:18 +0200
On Tue, May 8, 2012 at 6:33 PM, Fritz Anderson <email@hidden>wrote:
>
> I'll get this wrong if I answer in the amount of time I have. Look up
> "responder chain" in the Mac OS X documentation.
>
> To oversimplify:
>
> Menu commands typically go to the "first responder" — whatever has the UI
> focus. If the focused object doesn't implement the menu item's method, the
> event system shops the event up a logical hierarchy called the "responder
> chain" (e.g. text field -> window -> document -> application) until it
> finds an object that does implement the command. The first object that
> implements the command executes it.
>
> File > Save Document sends saveDocument: to the first responder. Because
> the chain goes from bottom up, the saveDocument: message arrives at the
> document object directly, without mediation from the application's document
> controller.
Thanks.
I apologize but I still don't quite understand. If I just
implement saveDocument: at the document and leave document controller
without it, the menu item is still disabled. When I add saveDocument: to
the controller as well, it works. I mean, if I try to visualize it, if I
just alloc:init: a document it just floats there in memory, how would a
menu know about it? So I need to create it via the document controller, no?
If this is the case, how to propagate the saveDocument: event though
the document controller to the document?
To put it differently, you seems to be saying that that the responder chain
flows the other way than what I thought. Ok, but then how does it know
about the document? When I were doing this in Xcode, I would just connect
the menu item to the first responder and the document from IB would receive
the saveDocument:, right? But there has to be a document controller, I
imagine it is somehow "implied" or "implicit" as in not exposed to the
user, which does the heavy lifting, do I understand this correctly? If so,
what exactly does this document controller do?
I'm sorry for such basic questions I'm very new to all this.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden