On 26/12/2011, at 9:05 AM, Luc Van Bogaert wrote:

> Hi,
> 
> I'm adding a custom user setting to a NSPrintPanel by adding an "accessory 
> view controller" for a view that contains just one control (a checkbox) and 
> which is loaded from a nib file. The checkbox's value has a binding to the 
> view controller's "representedObject.printSettings.checkboxvalue" keypath. 
> (The representedObject is a NSPrintInfo object).
> 
> I have been able to verify that this binding works correctly.
> 
> One thing I haven't gotten to work yet, is to automatically update the 
> "preview" in the print panel when I chance the state of the checkbox. The 
> preview updates itself correctly when I change one of the "built-in" 
> settings, and it even correctly represents my own custom setting. But, how 
> can I trigger an automatic update when I just change my own custom setting? 
> 
> I assume I should implement the  "keyPathsForValuesAffectingPreview" protocol 
> method in my accessory view controller, which I did, but so far without 
> success. Here's my implementation:
> 
> - (NSSet *)keyPathsForValuesAffectingPreview
> {
>    return [NSSet setWithObjects:
>            [NSString 
> stringWithFormat:@"representedObject.printSettings.checkboxvalue"],
>            nil];
> }
> 
> Any help much appreciated.
> 
> -- 
> Luc Van Bogaert


Well, I have added a print accessory view, but I'm not using bindings.

My accessory view controller implements this:

- (NSSet *)             keyPathsForValuesAffectingPreview
{
        return [NSSet setWithObjects:@"fitToSinglePage", @"cropMarks", 
@"printsGraphPaper", nil];
}


where the strings here are the names of properties implemented by the 
controller. I don't know how that translates to bindings, or on what object. 
It's a long time since I wrote this code, I forget much of the thought process 
that went into it, but it works reliably and I've never needed to look at it 
again. The controller makes changes to the NSPrintOperation object which it 
holds as a property.

Probably not much help, but you're on the right track, so persevere…..

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to