[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Position of I-beam cursor
From: |
Germán Arias |
Subject: |
Re: Position of I-beam cursor |
Date: |
Sat, 25 May 2013 19:32:15 -0600 |
User-agent: |
GNUMail (Version 1.2.0) |
Thanks. I want implement autocomplete for textview. So I need
know where to display the window with autocomplete suggestions.
I'm adding the code in NSTextView.m, not in NSTextView_actions.m.
I think this is the correct place, right?
I will submit a patch for review when ready.
Regards.
On 2013-05-25 06:40:40 -0600 Fred Kiefer <address@hidden> wrote:
> On 25.05.2013 09:16, Germán Arias wrote:
>> Is there a way to know the localization (x, y) of the I-beam in a textview?
>
> Internally we use _insertionPointRect but this isn't accessible from outside
> the NSTextView. The best you can do is to duplicate the code in the method
> -updateInsertionPointStateAndRestartTimer: to compute that rectangle
> yourself. I think this is the important code snipplet:
>
>
> new = [_layoutManager
> insertionPointRectForCharacterIndex:
> _layoutManager->_selected_range.location
> inTextContainer: _textContainer];
>
> new.origin.x += _textContainerOrigin.x;
> new.origin.y += _textContainerOrigin.y;
>
> /* If the insertion would extend outside the view (e.g. because it's
> just to the right of a character on the far right edge of the view,
> a common case for right-aligned text), we force it back in. */
> if (NSMaxX(new) > NSMaxX(_bounds))
> {
> new.origin.x = NSMaxX(_bounds) - new.size.width;
> }
>
> All the instance variables used here are available from the outside as well.
>
> Hope this helps
> Fred
>
>
> _______________________________________________
> Gnustep-dev mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gnustep-dev
>
>