Re: coordinate confusion, please help!
Re: coordinate confusion, please help!
- Subject: Re: coordinate confusion, please help!
- From: "Louis C. Sacha" <email@hidden>
- Date: Wed, 14 Jul 2004 19:46:31 -0700
Hello...
You can get the location of the click in the window's base
coordinates using the NSEvent instance method locationInWindow. If
you use the NSView convertPoint:fromView: instance method and pass
nil as the view to convert from, the point will be converted from the
base window coordinates into the coordinate system of your view.
- (void) mouseDown:(NSEvent *)theEvent
{
NSPoint locationInView = [self convertPoint:[theEvent
locationInWindow] fromView:nil];
/* ... whatever ... */
}
Hope that helps,
Louis
Hi,
I have created a custom view within a scrollview, it has various
elements on it which I want to be able to select with the mouse, I
have implemented the mouseDown: method and am trying to get the
coordinates on the click from the NSEvent that is delivered to it,
however the numbers don't make much sense, they seem to be relative
to the parent window, or even the whole screen. I have tried using
NSView' convertXXX methods, maybe I'm just being thick. but I still
can't figure it out.
Basicaly I want a 0,0 coordinate when I click the top-left corner of
my view (I am using isFlipped to flip the coordinates), it's in a
scrollview, so it can't be based on the position on the screen.
Thanks for any help
Moray
_______________________________________________
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.