• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextView problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView problems


  • Subject: Re: NSTextView problems
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 17 Jun 2002 10:33:04 -0700

On Sunday, June 16, 2002, at 02:40 AM, Nick Morris wrote:

I have some text in a subclass of NSTextView and all works OK. However, I wish to discover where text is being added. If I use NSLog to examine the NSLayoutManager that is associated with the NSTextView subclass I get (i.e. running a description):

<NSLayoutManager: 0xdf6300>
1 containers, text backing has 7 characters
selected character range {1, 0} affinty: upstream granularity: character
marked character range {7, 0}
Currently holding 7 glyphs with 0 glyph holes and 0 layout holes.
Glyph holes: ()
Layout holes: ()

The "selected character range" (effectively the point of insertion of new character) and "marked character range" contains just the information I need. However, I can not find a method that will return these values!

The selected and marked character ranges are actually attributes of the NSTextView; the layout manager just prints them for debugging purposes. However, the best way to discover where text is being added is naturally enough as the text view's delegate;

- (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;

allows you to be notified before text is added by the user, and to alter or veto the change, while

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

allows you to be notified after the change has occurred. Someone noted that the selectedRange and markedRange methods are defined in the NSTextInput protocol; this is true, but selectedRange is actually principally defined in the superclass NSText, while markedRange, because it is of interest only while an input method is active, is left to be defined in the protocol.

Douglas Davidson
_______________________________________________
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.

References: 
 >NSTextView problems (From: Nick Morris <email@hidden>)

  • Prev by Date: Re: Testing localization aspects of projects?
  • Next by Date: Re: Protecting Software w/ Software License Keys...
  • Previous by thread: Re: NSTextView problems
  • Next by thread: Wedgies anyone ?
  • Index(es):
    • Date
    • Thread