Dynamically added text views
Dynamically added text views
- Subject: Dynamically added text views
- From: April Gendill <email@hidden>
- Date: Fri, 29 Aug 2003 01:48:50 -0700
I gave up on what I'd been trying to do before. I just left it filling
the tab and set the other text field lower in the window.
anyway to dynamically add tabs to this window I wrote the code below,
along with something some one on the list offered in response to a
question i'd asked.
Here is the problem. I can add as many tabs as I want, as far as I can
tell. BUT, I cannot access the data in the darn textviews. In other
words, Since I obviously cannot connect this stuff in IB, how do I get
the text from the scrollview item into a NSString so I can save it once
it is edited?
-(void)addUserTabs:(int)dKey{
NSString *destination = [[[NSHomeDirectory()
stringByAppendingPathComponent:@"Library"]
stringByAppendingPathComponent:@"Preferences"]
stringByAppendingPathComponent:@"data.txt"];
NSMutableDictionary *defaults=[NSMutableDictionary
dictionaryWithContentsOfFile:destination];
if (dKey =1){
NSString * firstTab;
firstTab=[defaults objectForKey:@"0"];
if([firstTab length]==0){
firstTab =@"";
}
[itemViewOne setString:firstTab];
}
aTabItem = [[NSTabViewItem alloc]init];
NSRect scrollRect = NSMakeRect(0.0,16.0,359.0,532.0);
NSScrollView *theScrollView = [[NSScrollView alloc]
initWithFrame:scrollRect];
[theScrollView setHasVerticalScroller:YES];
[theScrollView setHasHorizontalScroller:NO];
[aTabItem setView:theScrollView];
[theScrollView setFrame:scrollRect];
NSTextView *theTextView = [[NSTextView alloc]
initWithFrame:[theScrollView frame]];
[theScrollView setDocumentView:theTextView];
NSString *pageName=[NSString stringWithFormat:@"Page %i",dKey+1];
NSString *pageIdent=[NSString stringWithFormat:@"Page%i",dKey+1];
[aTabItem setIdentifier:pageIdent];
[aTabItem setLabel:pageName];
[theTabs addTabViewItem:aTabItem];
NSString * currentString=[defaults objectForKey:[NSString
stringWithFormat:@"%i",dKey]];
[theTextView setString:currentString];
}
_______________________________________________
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.