• 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: Creating a nstextfield in a tab,
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a nstextfield in a tab,


  • Subject: Re: Creating a nstextfield in a tab,
  • From: Philip Dow <email@hidden>
  • Date: Thu, 15 Dec 2005 14:37:30 +0100

Hi Andrea,

If you need to have multiple copies of an NSTextView, try creating a master copy in Interface Builder. Put a view in the nib file and inside the view include an nstextview, which will automatically generate the necessary scrolling stuff.

Now sublcass NSObject and make your subclass the nib file owner. Inside the init method of your subclass, have it claim the nib file using [NSBundle loadNibNamed:@"MyNibFile" owner:self];

Also in your subclass, include a method that returns that main view. Then, whenever you need to add another text view to a tab, initialize your subclass, grab the main view that contains the text and scroll views using your custom method, and add that main view to the tab.

Hope that makes sense!
-Phil

On Dec 15, 2005, at 12:53 PM, Andrea Salomoni wrote:

Hi to all,

I need to create dynamically a certain number of tab that keeps inside an istance of nstextview.

NSTextView *chatView;
int a = [theTabView indexOfTabViewItemWithIdentifier:aNick];
if (a == NSNotFound)
{
id * lastTab;
NSTabViewItem * thePvtTab = [[NSTabViewItem alloc] initWithIdentifier:aNick];
[theTabView addTabViewItem:thePvtTab];
[thePvtTab setLabel:aNick];
NSScrollView *scrollview = [[NSScrollView alloc]
initWithFrame:NSMakeRect(0, 50, 500, 500)];
NSSize contentSize = [scrollview contentSize];
[scrollview setBorderType:NSGrooveBorder];
[scrollview setHasVerticalScroller:YES];
[scrollview setHasHorizontalScroller:NO];
chatView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0,contentSize.width, contentSize.height)];
[chatView setVerticallyResizable:YES];
[chatView setHorizontallyResizable:NO];
[chatView setAutoresizingMask:NSViewWidthSizable];
[chatView setMinSize:NSMakeSize(0.0, contentSize.height)];
[chatView setMaxSize:NSMakeSize(1e7, 1e7)];
[chatView setDrawsBackground:TRUE];
[chatView setBackgroundColor:[NSColor whiteColor]];
[chatView setEditable:TRUE];
[chatView setRichText:TRUE];
[chatView setSelectable:TRUE];
[[chatView textContainer] setContainerSize:contentSize];
[[chatView textContainer] setWidthTracksTextView:YES];
[scrollview setDocumentView:chatView];
[thePvtTab setView: scrollview];
[theTabView selectLastTabViewItem:(id)lastTab];
[chatView insertText:aMess];
}
else
{
NSTabViewItem * thePvtTab = [theTabView tabViewItemAtIndex:a];
NSScrollView * scrollview = [thePvtTab view];
chatView = [scrollview documentView];
[chatView insertText:aMess];
}
}
When I run the app all works (the threads too), but if a scroll the textview after some lines the app crash!
I think the problem is NSScrollView NSMakeRect
Where the last 500 is wrong...
How can I modify it to mantain the scroll infinite?
thks
_______________________________________________
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


_______________________________________________
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: 
 >Creating a nstextfield in a tab, (From: Andrea Salomoni <email@hidden>)

  • Prev by Date: Getting a 128x128 icon for a file or file type
  • Next by Date: Re: Getting a 128x128 icon for a file or file type
  • Previous by thread: Creating a nstextfield in a tab,
  • Next by thread: Re: Creating a nstextfield in a tab,
  • Index(es):
    • Date
    • Thread