Re: More on text views
Re: More on text views
- Subject: Re: More on text views
- From: "Alastair J.Houghton" <email@hidden>
- Date: Fri, 29 Aug 2003 11:33:57 +0100
On Friday, August 29, 2003, at 06:58 am, April Gendill wrote:
aTabItem = [[NSTabViewItem alloc]init];
NSRect scrollRect = NSMakeRect(16.0,0.0,342.0,532.0);
NSScrollView *theScrollView = [[NSScrollView alloc]
initWithFrame:scrollRect];
[theScrollView setHasVerticalScroller:YES];
[theScrollView setHasHorizontalScroller:NO];
[aTabItem setView:theScrollView];
Use [[aTabItem view] addSubview:theScrollView] instead of -setView.
The former adds a sub-view to the view that is already inside the tab,
whereas the latter replaces the view already within the tab, which is
why it is always the full size of the tab.
Part 2 I need to add a textfield that has no background... and I don't
see any method for adding textfields to a view programatically.
You can add *any* view to another view using -addSubview:. If you look
at the class hierarchy, you'll find that NSTextField is a subclass of
NSControl, which in turn is a subclass of NSView. So you can do e.g.
[[aTabItem view] addSubview:myTextField];
All Cocoa controls are subclasses of NSView, so this will work for all
of them.
Thing with this is I need this text field to also center it's text and
I see nothing to do that either...
Try -setAlignment: (it's a method on NSControl). If you haven't
already, get AppKiDo; you could easily have found this either by
choosing "ALL Instance Methods" whilst examining NSTextField, or by
proceeding up the inheritance hierarchy to NSControl.
Question 2... is there a was to dupelicate a tab's structure and not
have to futz with all the extra stuff? If it's possible I could simply
copy a tabview item, define it's text string and move on with my life.
It doesn't appear to support NSCopying, so you can't just send -copy to
get another one the same. AFAIK the best you can do is what you're
already doing, although someone else might have a better idea.
Kind regards,
Alastair.
_______________________________________________
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.