• 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: I want NSTextView to grow horizontally as text is entered
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I want NSTextView to grow horizontally as text is entered


  • Subject: Re: I want NSTextView to grow horizontally as text is entered
  • From: SA Dev <email@hidden>
  • Date: Wed, 11 May 2005 08:22:46 -0400

Ian:

The same theory applies. I adapted that exact example for my own purposes. It was a bit of a learning experience, but then again you get nowhere by having code handed to you. ;-) Just take a look at the docs (the text system overview, I think) and see how an NSTextView is constructed. That'll clue you in on what to adapt in the example you were pointed to.




On May 11, 2005, at 4:09 AM, Ian Jackson wrote:

Thanks Ryan,

Unfortunately, my original subject line was wrong and misleading. I meant to say NSTextView (as it is now), not NSTextField. So I tried out your link, but it wasn't what I was looking for. Any other clues?

Ian.


On 11/05/2005, at 2:25 AM, Ryan Stevens wrote:


http://www.cocoadev.com/index.pl?CCDGrowingTextField

On May 9, 2005, at 1:37 AM, Ian Jackson wrote:


Hi,

I've been looking around for a solution to this problem, and there certainly seem to be people who can make this work, but after gathering together everything I understand about the text architecture, it just doesn't work. So with an NSView in a window, this was my attempt to make the simplest possible application to figure it out.

- (void)drawRect:(NSRect)rect
{

    [self setAutoresizesSubviews:YES];

    textStorage = [[NSTextStorage alloc] init];

    NSLayoutManager *layoutManager;
    layoutManager = [[NSLayoutManager alloc] init];
    [textStorage addLayoutManager:layoutManager];
    [layoutManager release];

NSRect cFrame = [[[self window] contentView] frame];
NSTextContainer *container;
container = [[NSTextContainer alloc] initWithContainerSize:cFrame.size];
[container setWidthTracksTextView:NO];
[layoutManager addTextContainer:container];
[container release];



NSRect tvRect; tvRect.origin.x = 150; tvRect.origin.y = 150; tvRect.size.width = 100; tvRect.size.height = 100;

NSTextView *theTextView = [[NSTextView alloc] initWithFrame:tvRect textContainer:container];
[theTextView setPostsFrameChangedNotifications:YES];
[theTextView setHorizontallyResizable:YES];
[theTextView setAutoresizingMask:NSViewNotSizable];
[self addSubview:theTextView];
[theTextView release];
}


So this should be a fairly standard implementation of NSTextStorage, NSLayoutManager, etc. What I hope to happen is that as I type in the NSTextView the rect initially described by tvRect should grow and display text. But what actually happens is that the text continues on, but doesn't display till it gets to the edge of the container rect, when it starts on the next line of the NSTextView. I think there are only a few superfluous lines (e.g. setAutoresizesSubviews) but I really want to know what the key thing is that I'm missing. Thank you. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40silentalcove.net


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: I want NSTextView to grow horizontally as text is entered
      • From: Ian Jackson <email@hidden>
References: 
 >I want NSTextField to grow as text is entered (From: Ian Jackson <email@hidden>)
 >Re: I want NSTextField to grow as text is entered (From: Ryan Stevens <email@hidden>)
 >I want NSTextView to grow horizontally as text is entered (From: Ian Jackson <email@hidden>)

  • Prev by Date: QTKit: QTMovieTimeDidChangeNotification
  • Next by Date: NSImage is making me lose what's left of my hair.
  • Previous by thread: I want NSTextView to grow horizontally as text is entered
  • Next by thread: Re: I want NSTextView to grow horizontally as text is entered
  • Index(es):
    • Date
    • Thread