Very newbie question
Very newbie question
- Subject: Very newbie question
- From: Peter Benson <email@hidden>
- Date: Sun, 8 Jun 2003 14:28:22 -0500
I'm just starting out in Cocoa programming, and I'm trying to write a
selection rectangle class (or really, modify it from some sample code I
found at ADC called "Cropped Image"). I'm trying to NSLog the x,y
coordinates of mouseDown and mouseUp events after using convertPoint,
something like this:
#define WHERE [target convertPoint:[theEvent locationInWindow]
fromView:nil]
- (void) mouseUp:(NSEvent *) theEvent
{
int xDiff = (WHERE.x - lastLocation.x);
int yDiff = (WHERE.y - lastLocation.y);
NSLog(@"mouseUp:");
NSLog(@"x location in window: %d",WHERE.x);
NSLog(@"y location in window: %d",WHERE.y);
NSLog(@"x difference: %d",xDiff);
NSLog(@"y difference: %d",yDiff);
lastLocation = WHERE;
}
This works to an extent- the xDiff and yDiff values logged are
reasonable (ie seem like the proper number of pixels between
consecutive mouseUp events) but WHERE.x and WHERE.y are logged as 10
digit numbers (clicking in the left upper corner of the view gives
1075052544, for instance). I thought convertPoint would produce x,y
coordinates in pixels relative to the window- something like 0,138. I
get the same sort of 10 digit output if I try to NSLog myRect.origin.x
or myRect.size.height.
I imagine this is something simple, but it's really got this newbie
stuck- can anyone set me right?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.