• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Binding with value transformer enigma
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding with value transformer enigma


  • Subject: Binding with value transformer enigma
  • From: Francis Derive <email@hidden>
  • Date: Thu, 5 Jan 2006 15:44:38 +0100

Bonjour !

I want to display the x and y coordinates of the mouse current point while dragging the mouse over the view.

@interface FdeGradientView : NSView {
	[..]
	NSValue *currentPoint;
}

[accessor methods]

@end


currentPoint value is given through the view's mouseDown, mouseDragged, and mouseUp methods.
It is exposed as a binding in the view's +initialize method, and so I will bind it in IB to testerCurrentPoint in the tester controller app which uses the view : currentPointer = testerCurrentPoint [FdeGradientViewTester (FdeGradientViexwTester)]



@interface FdeGradientViewTester : NSObject {
	[...]
	NSValue *testerCurrentPoint;
}

[accessor methods]

@end



Then, in the tester app, besides the view, I have 2 NSTextField which I want them to receive their value from a binding to the same testerCurrentPoint, but with two different NSValueTransformers - xProjection and yProjection.


For example NSTextField value = xProjection(testerCurrentPoint) [FdeGradientViewtester (FdeGradientViewTester)]

These xProjection and yProjection value transformers have been registered in an +initialize method, once it was in the tester app, then it was in an additional and distinct app delegate class.


The PRojx NSValueTransformer class is like that :
@implementation PRojx

+ (Class) transformedValueClass {
	return [NSNumber class];
}

+ (BOOL) allowsReverseTransformation {
	return NO;
}

- (id) transformedValue:(id) inValue {
NSLog(@" PRojx -- transformedValue %@", [inValue class]); <<<<<<<<<<<<<<<< NULL !
if ([[inValue className] isEqualToString:@"NSValue"]) {
NSLog(@" PRojx -- transformedValue FIN");
return [NSNumber numberWithFloat:[inValue pointValue].x];
} else {
NSLog(@" PRojx -- transformedValue FIN NIL"); <<<<<<<<<<<<<<<<<< HERE WE ARE !
return nil;
}
}


@end


But no display of the varying coordinates ... !
This is a trace log :

[Session started at 2006-01-05 15:28:20 +0100.]
2006-01-05 15:28:21.802 FdeGradientViewTester[1089] 440.000000 -- 271.000000
2006-01-05 15:28:22.277 FdeGradientViewTester[1089] FdeGradientViewTester - initialize
2006-01-05 15:28:22.312 FdeGradientViewTester[1089] FdeGradientViewTester - initialize FIN
2006-01-05 15:28:22.361 FdeGradientViewTester[1089] Deleg - initialize
2006-01-05 15:28:22.366 FdeGradientViewTester[1089] Deleg - initialize FIN
2006-01-05 15:28:22.474 FdeGradientViewTester[1089] PRojx -- transformedValue (null) <<<<<<<<<<<<<<<<<
2006-01-05 15:28:22.475 FdeGradientViewTester[1089] PRojx -- transformedValue FIN NIL <<<<<<<<<<<<<<<<<
2006-01-05 15:28:22.481 FdeGradientViewTester[1089] FdeGradientViewTester -- awakeFromNib valueTransformerNames
2006-01-05 15:28:22.482 FdeGradientViewTester[1089] FdeGradientViewTester -- awakeFromNib valueTransformerNames count 6
2006-01-05 15:28:22.483 FdeGradientViewTester[1089] -- awakeFromNib valueTransformerNames i 0 name NSIsNotNil
2006-01-05 15:28:22.483 FdeGradientViewTester[1089] -- awakeFromNib valueTransformerNames i 1 name NSUnarchiveFromData
2006-01-05 15:28:22.483 FdeGradientViewTester[1089] -- awakeFromNib valueTransformerNames i 2 name NSIsNil
2006-01-05 15:28:22.483 FdeGradientViewTester[1089] -- awakeFromNib valueTransformerNames i 3 name yProjection
2006-01-05 15:28:22.483 FdeGradientViewTester[1089] -- awakeFromNib valueTransformerNames i 4 name NSNegateBoolean
2006-01-05 15:28:22.484 FdeGradientViewTester[1089] -- awakeFromNib valueTransformerNames i 5 name xProjection
2006-01-05 15:28:24.719 FdeGradientViewTester[1089] mouseDown:
2006-01-05 15:28:24.720 FdeGradientViewTester[1089] x = 79.000000 y = 97.000000
2006-01-05 15:28:24.937 FdeGradientViewTester[1089] mouseDragged:
2006-01-05 15:28:24.937 FdeGradientViewTester[1089] x = 80.000000 y = 97.000000
[...]
2006-01-05 15:28:25.926 FdeGradientViewTester[1089] mouseUp:
2006-01-05 15:28:25.993 FdeGradientViewTester[1089] x = 177.000000 y = 114.000000


Sorry for not being shorter in my presentation, and merci beaucoup for your help.

Cheers.



_______________________________________________
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


  • Prev by Date: Internationalization support
  • Next by Date: Determining Available SMB Shares
  • Previous by thread: Re: Internationalization support
  • Next by thread: Determining Available SMB Shares
  • Index(es):
    • Date
    • Thread