• 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
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView


  • Subject: Re: NSTextView
  • From: "email@hidden" <email@hidden>
  • Date: Wed, 22 Sep 2010 12:34:07 +0100

>
>
> On Sep 22, 2010, at 4:03 AM, albert jordan wrote:
>
>>
>> I have setup an "NSTextView in an NSScrollView" item in interface builder, and my window controller objects has an IBOutlet that is linked to TextView of the item (if I connect it to the NSScrollView, I don't get any text).  Anytime that I get a log statement, I use the insert text method to print out the log line in the view...
>>
>> [myTextView insertText: (NSString *) newLogLine];
>>
>>
I found the following configuration useful when logging to an NSTextView instance

	[[_textView layoutManager] setBackgroundLayoutEnabled:YES];
	[[_textView layoutManager] setAllowsNonContiguousLayout:YES];

I also add the following in an NSTextView subclass to append a string and scroll it visible.

- (void)addStringAndScrollToVisible:(NSString *)string
{
	NSRange endRange;

	@try{

		endRange.location = [[self textStorage] length];
		endRange.length = 0;

		[self replaceCharactersInRange:endRange withString:string];
		endRange.length = [string length];

		// note that this method can be very slow for large amounts of text.
                //depending on how the textview is configured
		[self scrollRangeToVisible:endRange];

	} @catch (NSException *e){
		NSLog(@"Exception scrolling NSTextView: %@", [e name]);
	}
}

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.com_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSTextView (From: albert jordan <email@hidden>)
 >Re: NSTextView (From: Martin Hewitson <email@hidden>)

  • Prev by Date: Re: NSTextView
  • Next by Date: Sockets and runloop sources
  • Previous by thread: Re: NSTextView
  • Next by thread: Re: NSTextView
  • Index(es):
    • Date
    • Thread