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

Re: NSLayoutManager strangeness


  • Subject: Re: NSLayoutManager strangeness
  • From: Satoshi Matsumoto <email@hidden>
  • Date: Fri, 05 Aug 2005 18:22:17 +0900

on 05.8.5 1:57 PM, Duncan Campbell at email@hidden wrote:
> However, if I try to use my own NSLayoutManager, my draw code does
> not work correctly until i press a key.
>
> Even if I simply do:
>
>          NSLayoutManager *lm = [[NSLayoutManager alloc] init];
>          [[self textContainer] replaceLayoutManager:lm];
>          [lm release];
>
> In my NSTextView's initWithFrame: (i.e. no subclass code at all)
> things break.

Try the code below in your awakeFromNib  of NSTextView subclass.

Because the hierarchy of the text system is:
NSTextStrage->NSLayoutManager->NSTextContainer->NSTextView

- (void)awakeFromNib
{
NSLayoutManager *oldLayoutManager;
NSLayoutManager *newLayoutManager;
NSTextContainer *textContainer;
NSTextStorage *text = [self textStorage];

    oldLayoutManager = [self layoutManager];
    newLayoutManager = [[NSLayoutManager alloc] init];
    textContainer = [self textContainer];
    [textContainer retain];
    [oldLayoutManager removeTextContainerAtIndex:0];
    [newLayoutManager addTextContainer:textContainer];
    [text addLayoutManager:newLayoutManager];
    [text removeLayoutManager:oldLayoutManager];
    [textContainer release];
    [newLayoutManager release];

    .......
}

Satoshi
-----------------------------------------------------
Satoshi Matsumoto <email@hidden>
816-5 Odake, Odawara, Kanagawa, Japan 256-0802


 _______________________________________________
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

References: 
 >NSLayoutManager strangeness (From: Duncan Campbell <email@hidden>)

  • Prev by Date: NEWBIE: Multiple class communication without DO
  • Next by Date: Re: Forcing a scroll to the top of an NSScrollView
  • Previous by thread: NSLayoutManager strangeness
  • Next by thread: NSLayoutManager strangeness
  • Index(es):
    • Date
    • Thread