Bindings on Custom View (Initial Value)
Bindings on Custom View (Initial Value)
- Subject: Bindings on Custom View (Initial Value)
- From: Stefan Arentz <email@hidden>
- Date: Fri, 20 Jun 2008 23:51:27 -0400
With help from mmalc's binding examples I pretty much got the bindings
on my custom view working.
I uploaded the app to:
http://kip.sateh.com/BindableGradientViewWithObjectController/
http://kip.sateh.com/BindableGradientViewWithObjectController.zip
(First link is source, second is an archive that contains source
+project+compiled app)
It's a pretty basic example .. there is a GradientView that takes two
bindings, startingColor and endingColor. These are set with two Color
Wells and everything is connected with an NSObjectController. Click a
color well and select a color to see the gradient change.
The only thing that I am not sure about is that I need to have the
following in my GradientView's bind: method:
- (void) bind: (NSString*) name toObject: (id) object withKeyPath:
(NSString*) path
options: (NSDictionary*) options
{
// ... do the binding ...
// ??? Without this setValue the initial values are not
passed to the view
[self setValue: [object valueForKeyPath: path] forKey: name];
// Refresh the view
[self setNeedsDisplay: YES];
}
The binding examples from mmalc are not doing the setValue but without
it my view keeps it's default colors instead of the colors that I am
explicitely setting in my controller. The Color Wells are picking up
this color.
I'm binding the GradientView with:
- (void) awakeFromNib
{
[gradientView bind: @"startingColor" toObject: objectController
withKeyPath: @"selection.startingColor" options:
[NSDictionary dictionaryWithObject: [NSNumber
numberWithBool:YES]
forKey: @"NSContinuouslyUpdatesValue"]];
[gradientView bind: @"endingColor" toObject: objectController
withKeyPath: @"selection.endingColor" options:
[NSDictionary dictionaryWithObject: [NSNumber
numberWithBool:YES]
forKey: @"NSContinuouslyUpdatesValue"]];
}
Is there maybe an option that I need to set to force an initial update?
S.
_______________________________________________
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