Re: NSTextField or NSTextView for this job?
Re: NSTextField or NSTextView for this job?
- Subject: Re: NSTextField or NSTextView for this job?
- From: Brent Stace <email@hidden>
- Date: Sat, 9 Oct 2004 20:35:12 -0400
hey,
I stumbled along this code a long time ago on the web when I was
looking on how to programmatically insert buttons/button cells in
cocoa. It does have some code on what looks like measuring
text/font/string size. It may put you on the right path for your
second implementation, or give you some ideas...hope it helps!
In my program code, though, I have this whole part commented out
because I don't understand why button height should change based on OS,
but I plan to investigate that later.
/*some button same code*/
// the size of the button is controlled by the local message font
// by passing in "-1.0", it means "use the system's default size"
#ifdef OSX_SERVER
#define BUTTON_HEIGHT 24.0
#else
#define BUTTON_HEIGHT 34.0
#endif
button = [[NSButton allocWithZone:zone ]
initWithFrame:NSMakeRect(1.0,originY,[[NSFont
messageFontOfSize:-1.0] widthOfString:s] + 30.0
,BUTTON_HEIGHT)];
------------------------
Brent Stace
email@hidden
On Oct 9, 2004, at 10:16 AM, Jerry Krinock wrote:
I want my users to view of text which will never wrap lines but show
horizontal and/or vertical scrollbars to appear as needed.
I'm playing with two possible solutions:
1. NSTextView in an NSScrollView. From searching the archives
www.cocoabuilder.com, I see many methods but they all look complicated
and
kludgy, so I thought of this:
2. NSTextField in an NSScrollView. This would work if I resized the
NSTextField frame to just fit the text. Scrollbars automatically
appear
whenever the NSTextView is too big for the NSScrollView. But I need a
way
to compute the size of the required frame. I remember in the old days
of
"Inside Macintosh" there were functions for "measuring" displayed
text. Is
there anything like that in Cocoa?
Which way should I go with this?
_______________________________________________
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