• 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
Re: Very newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Very newbie question


  • Subject: Re: Very newbie question
  • From: Henry McGilton <email@hidden>
  • Date: Sun, 8 Jun 2003 15:07:27 -0700

On Sunday, June 8, 2003, at 12:28 PM, Peter Benson wrote:

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?


The coordinate system uses float, not int.

Best Wishes,
........ Henry


===============================+============================
Henry McGilton, Boulevardier | Trilithon Software
Objective-C/Java Composer | Seroia Research
-------------------------------+----------------------------
mailto:email@hidden | http://www.trilithon.com
|
===============================+============================
_______________________________________________
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.

References: 
 >Very newbie question (From: Peter Benson <email@hidden>)

  • Prev by Date: Re: C question for you old guys ;-)
  • Next by Date: Re: IB and NSImageView
  • Previous by thread: Very newbie question
  • Next by thread: Re: New Mac Developer looking for advice
  • Index(es):
    • Date
    • Thread