Re: Vertically-expanding NSTextField
Re: Vertically-expanding NSTextField
- Subject: Re: Vertically-expanding NSTextField
- From: Andrew Bowman <email@hidden>
- Date: Fri, 12 May 2006 02:03:28 -0700
On May 11, 2006, at 1:24 PM, Brian Ganninger wrote:
Although the codebase isn't exactly small or quick to sort through,
Adium (http://www.adiumx.com) has such a textfield and is open
source, so you can fully peruse the code that makes this happen.
Great suggestion! I found the source for this, but it's a subclass
for an NSTextView, which complicates things a little. Here's the
path to the implementation file in the source:
"adium-0.89/Frameworks/Adium Framework/AIMessageEntryTextView.m"
The Auto Sizing section is clearly marked and has what I'm looking for.
I was able to use two lines of the desiredSize method in my test
code, replacing the "self" calls with the field editor.
This worked fairly well, but after the field was stretched
vertically, I did not receive NSViewFrameDidChangeNotifications from
the field editor when I deleted enough text to warrant a contraction
of the textfield. I was able to get this working wonderfully by
calling my autosize function from the textDidChange method, however.
The autosizing expands the textfield upward, so I had to include a
translation down by the expansion size to make it a downward
expansion instead.
Since I'm trying to mimic the behavior of an iChat message window, I
wanted the window to expand downward with the field. I was able to
get this working nicely, but it causes a problem with other IB
elements, which try to autosize in response to the window's
resizing. Is there a way to temporarily halt the autosizing of
NSViews? I tried using [[[self window] contentView]
setAutoresizesSubviews: NO], then reenabling it after the window
resize, but with no effect. Tinkering with the autoresizing masks
for various views didn't work either. The only solution I have so
far is to manually translate views up by the expansion size, but this
produces brief artifacts, and would be difficult to apply to more
complex window layouts. I imagine that I'll run into the exact same
problem if I try to use an expanding NSTextView instead. Any
suggestions here?
- Andrew Bowman
_______________________________________________
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