gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Position of I-beam cursor


From: Fred Kiefer
Subject: Re: Position of I-beam cursor
Date: Sat, 25 May 2013 14:40:40 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]