Coordinate Systems
Coordinate Systems
- Subject: Coordinate Systems
- From: Tom Gray <email@hidden>
- Date: Thu, 10 Oct 2002 08:04:15 -0400
Hi,
I am trying to improve my understanding of locationInWindow and
characterIndexForPoint. What I am attempting to do is get the index of
a character in a NSTextView underneath a mouse click. I using the
NSEvent method locationInWindow to get the mouse click location.
-------
locationInWindow
- (NSPoint)locationInWindow
Returns the receiver's location in the base coordinate system of the
associated window.
-------
This method returns the location of the mouse click in the "base"
system. From my tests this seems to be based on the lower left corner
of the window the NSTextView is contained it. It is screen position
independent.
Once I have the point of the mouse click, I am trying to determine
which character was clicked on by using the method
characterIndexForPoint with the string associated with the
NSTextStorage of my NSTextView. ([myTextStorage string]).
-------
characterIndexForPoint:
- (unsigned int)characterIndexForPoint:(NSPoint)thePoint
Returns the index of the character whose frame rectangle includes
thePoint. The returned index measures from the start of the receiver's
text storage. thePoint is in the screen coordinate system.
-------
Here's the question... it seems characterIndexForPoint requires a
"screen" coordinate and locationInWindow returns a "window centric
coordinate", so, do I need to convert my "window centric coordinate" to
a "screen" coordinate for this method to work for me?
Anybody know why this method requires a screen coordinate and not a
window coordinate?
Tom Gray
-------------
email@hidden
or
email@hidden
_______________________________________________
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.