• 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
Building Text System by hand - View Displays Nothing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Building Text System by hand - View Displays Nothing


  • Subject: Building Text System by hand - View Displays Nothing
  • From: Michael Hanna <email@hidden>
  • Date: Mon, 1 Nov 2004 19:45:19 -0500

Hello,

I'm building the text system by hand for my app like it's set up in Figure 4 of:

file:///Developer/ADC Reference Library/documentation/Cocoa/ Conceptual/TextArchitecture/Concepts/CommonConfigs.html

so that the two NSTextViews are viewing the same document. They are inside an NSSplitView. The NSTextViews and the NSSplitView are archived in the MyDocument.nib.

in the MyDocument -init method I have:

		myDocumentTextStorage = [[NSTextStorage alloc] init];
		myDocumentString = [[[NSMutableAttributedString alloc] init] retain];

		myTopLayoutManager = [[NSLayoutManager alloc] init];
		[myDocumentTextStorage addLayoutManager:myTopLayoutManager];
		[myTopLayoutManager release];

		myBottomLayoutManager = [[NSLayoutManager alloc] init];
		[myDocumentTextStorage addLayoutManager:myBottomLayoutManager];
		[myBottomLayoutManager release];


inside my awakeFromNib I use replaceTextContainer to have the NSTextViews conform to my hand-built text-system:


- (void)awakeFromNib {

NSRect topTextViewFrame = [myTopTextView frame];
NSRect bottomTextViewFrame = [myBottomTextView frame];

// create the NSTextContainers now, now that the textviews are referenceable

myTopTextContainer = [[NSTextContainer alloc] initWithContainerSize:topTextViewFrame.size];
[myTopLayoutManager addTextContainer:myTopTextContainer];
[myTopTextContainer release];

myBottomTextContainer = [[NSTextContainer alloc] initWithContainerSize:bottomTextViewFrame.size];
[myBottomLayoutManager addTextContainer:myBottomTextContainer];
[myBottomTextContainer release];

[myTopTextView replaceTextContainer:myTopTextContainer];
[myBottomTextView replaceTextContainer:myBottomTextContainer];


		......
}

the user opens a file using initWithPath:

- (void)openVisualFilePanelDidEnd:(NSOpenPanel *)openPanel
returnCode:(int)returnCode
contextInfo:(void *)x
{
NSMutableAttributedString *theString;
if(returnCode == NSOKButton) {
[prompter setVisualPromptPath:[openPanel filename]];
[self updateChangeCount:NSChangeDone];
theString = [[NSMutableAttributedString alloc] initWithPath:[openPanel filename] documentAttributes:nil];

[self setDocumentString:theString];
[self updateUI];
[theString release];

}
}



inside setDocumentString I go:

	[myDocumentTextStorage setAttributedString:theString];

I am certain by this time the NSMutableAttributedString is set to the NSTextStorage because I set a breakpoint and typed 'po myDocumentTextStorage' to see its contents(the string is there)

finally in updateUI I sent setNeedsDisplay to all the Views...but it still comes up blank.

	[myTopTextView setNeedsDisplay:YES];
	[myBottomTextView setNeedsDisplay:YES];
	[mySplitView setNeedsDisplay:YES];


any ideas why the views are blank? I used file:///Developer/ADC Reference Library/documentation/Cocoa/ Conceptual/TextArchitecture/Tasks/AssembleSysByHand.html


to help me with this whole task.

best regards,
Michael

_______________________________________________
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


  • Prev by Date: Re: htonl network byte ordering for 64 bit words...
  • Next by Date: binding nsmatrix selection
  • Previous by thread: Re: htonl network byte ordering for 64 bit words...
  • Next by thread: binding nsmatrix selection
  • Index(es):
    • Date
    • Thread