NSTextView Insertion point question

  • How do you get the location of the insertion point?  I am making a real
    time text editor and when the insertion point is changed I can not find
    a way to get where it was changed to.  Thanks for any help
  • On Sunday, April 22, 2001, at 09:04  PM, Aaron Spjut wrote:

    > How do you get the location of the insertion point?  I am making a real
    > time text editor and when the insertion point is changed I can not find
    > a way to get where it was changed to.  Thanks for any help

    NSTextView has the concept of a selected character range.  You will see
    a blinking insertion point only if the length of the selected character
    range is 0; otherwise the selected range will be highlighted.  To find
    out what the selected character range is, use (from the superclass in
    NSText.h):

    - (NSRange)selectedRange;

    The textview's delegate can intervene before the selected range is
    changed, and approve or alter any changes with

    - (NSRange)textView:(NSTextView *)textView
    willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
    toCharacterRange:(NSRange)newSelectedCharRange;

    Any interested party can receive the
    NSTextViewDidChangeSelectionNotification to be notified of selection
    changes; the delegate will automatically receive it as

    - (void)textViewDidChangeSelection:(NSNotification *)notification;

    Douglas Davidson
previous month april 2001 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Go to today