Stuck in basic bindings
Stuck in basic bindings
- Subject: Stuck in basic bindings
- From: Francis Derive <email@hidden>
- Date: Tue, 17 Jan 2006 17:26:04 +0100
Bonjour la liste,
I have been working a big while ( subject = "Binding with value
transformer enigma" ) and I would appreciate some help from the list.
I have changed the architecture to make it simpler and more sound to
me, but still a problem.
From a custom palette, I get a view and I want to display the x and
y coordinates of the mouse downs, drags, and ups.
@interface fdeGradientView : NSView {
[...]
NSPoint mouseLocation;
float mouseXlocation;
float mouseYlocation;
}
It is not Core Data.
I use "Basic Accessor Methods" for mouseLocation ivar ( because
simple NSPoint type).
I no more bind from the NSPoint to a corresponding instance variable
of a tester model object.
Rather, I make immediately mouseXlocation and mouseYlocation depend
on mouseLocation :
- I declare the dependency in the view +initialize
- in the same +initialize, I expose the mouseXlocation and
mouseYlocation for binding
+ (void)initialize {
NSArray *keys = [NSArray arrayWithObjects:@"mouseLocation", nil];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"mouseXlocation"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"mouseYlocation"];
[...]
[self exposeBinding:@"mouseXlocation"];
[self exposeBinding:@"mouseYlocation"];
}
In fact, I have not to go far away from the view, because it appears
that the dependent properties mouseXlocation and mouseYlocation are
not set in the view:
[Session started at 2006-01-17 16:44:58 +0100.]
2006-01-17 16:45:01.758 fdeGradientViewUser[2564]
FDGradientViewUser -- testerXlocation:0.000000
2006-01-17 16:45:01.784 fdeGradientViewUser[2564]
FDGradientViewUser -- testerXlocation:0.000000
2006-01-17 16:45:01.788 fdeGradientViewUser[2564]
FDGradientViewUser -- testerXlocation:0.000000
2006-01-17 16:45:01.808 fdeGradientViewUser[2564]
FDGradientViewUser -- testerXlocation:0.000000
2006-01-17 16:45:03.906 fdeGradientViewUser[2564] fdeGradientView
-- mouseDown - mouseLocation.x:231.000000 mouseLocation.y:74.000000
2006-01-17 16:45:03.907 fdeGradientViewUser[2564] fdeGradientView
-- mouseDown - mouseXlocation:0.000000 mouseYlocation:0.000000
<<<<<<<<<<<<<<
2006-01-17 16:45:03.974 fdeGradientViewUser[2564] fdeGradientView
-- mouseUp - mouseLocation.x:231.000000 mouseLocation.y:74.000000
2006-01-17 16:45:03.976 fdeGradientViewUser[2564] fdeGradientView
-- mouseUp - mouseXlocation:0.000000 mouseXlocation:0.000000
<<<<<<<<<<<<<<<<
with
- (void) mouseDown:(NSEvent *)event {
mouseLocation = [self convertPoint:[event locationInWindow]
fromView:nil];
NSLog(@"fdeGradientView -- mouseDown - mouseLocation.x:%f
mouseLocation.y:%f", mouseLocation.x, mouseLocation.y);
NSLog(@"fdeGradientView -- mouseDown - mouseXlocation:%f
mouseYlocation:%f", mouseXlocation, mouseYlocation);
[self setNeedsDisplay:YES];
}
and
- (float) mouseXlocation {
return [self mouseLocation].x;
}
I thank you enormously for any progress I could make on this damned
promising binding subject.
Cheers,
Francis.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden