[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Position of I-beam cursor
From: |
Eric Wasylishen |
Subject: |
Re: Position of I-beam cursor |
Date: |
Sun, 26 May 2013 14:02:03 -0400 |
Hi Germán,
> Not the mouse cursor, is the i-beam cursor. I don't have a Mac to see how
> this works under Cocoa. But, for example, in this image:
>
> http://www.creativetechs.com/iq/tip_images/OSX-Autocomplete.png
>
> I imagine the window appears under the word you are typing. So, I need
> know where is typing the user.
>
> Germán.
Sounds like a cool project! The I beam is called the "insertion point" in
NSTextView. You can get the character index of it using
[self selectedRange]
inside NSTextView. The I-beam is only present if length == 0 and location !=
NSNotFound.
To get the (x,y) coordinates for positioning the popup window, you can use
-firstRectForCharacterRange:. (NSTextInput protocol). Note that apple's docs
say this returns a result in screen coordinates, but our NSTextView's
implementation doesn't seem to do that.
Eric