Re: printing and the responder chain
Re: printing and the responder chain
- Subject: Re: printing and the responder chain
- From: Graham Cox <email@hidden>
- Date: Tue, 04 Oct 2011 22:22:07 +1100
On 04/10/2011, at 9:23 PM, Torsten Curdt wrote:
> "Printing is generally initiated by the user choosing the Print menu
> command, which usually sends either a print: or printDocument:
> message,
So which is it? You can look at the Print menu item in the MainMenu.xib and see what its action and target are set to. Target is likely to be nil (first responder) but you can set it directly to be the view if it's defined in MainMenu.xib. That will help avoid the message going to the wrong object in the simple case where there are not multiple windows that can become the target for Print at different times.
> Now I expected "Print" would only execute the NSLog. But still the
> print dialog comes up and has the NSOutlineView only in the preview.
In order for your custom view to become first responder, it must also return YES from -acceptsFirstResponder but mouse events in the outline view can change that to be first responder, so to avoid unexpected surprises with Print, I suggest you set the view to be the menu item's direct target. NSView has a default implementation of print (inherited by NSOutlineView).
Also, to set the custom view to be the initial first responder, you can connect the window's initialFirstResponder outlet to it, to save having to do that in -awakeFromNib, but that still requires that the view acceptsFirstResponder to function.
--Graham
_______________________________________________
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