setHorizontallyResizable, setWidthTracksTextView, and alignment
setHorizontallyResizable, setWidthTracksTextView, and alignment
- Subject: setHorizontallyResizable, setWidthTracksTextView, and alignment
- From: Jeff Argast <email@hidden>
- Date: Mon, 16 Feb 2004 16:13:04 -0700
Hello-
I want my NSTextView to grow horizontally as the user types text. If
the user hits enter I want the text view to grow vertically. I have
accomplished that goal by calling the appropriate methods on NSTextView
and NSTextContainer. But if I apply center alignment, the width of the
text view suddenly grows very wide and the text remains aligned left.
Is there a simple way to keep the width of the view as wide as the
widest line and yet center the text?
The easiest way to see this problem is via Apple's TextSizingExample
found with the developer tools. Build it, run it, select all text,
choose the menu item Format->Text->Center (Note that the text is
centered), then click on the popup and choose non-wrapping scrolling
text. The result is left aligned text in a very wide text view (the
width of the text view is evident by the appearance of the scrolling
nib on the bottom). For further fun, select all text and delete it.
Notice the horizontal scroll bar has disappeared and the flashing text
caret is in the middle of the first line -- all exactly as expected.
Now type a character. It does not appear where the text caret said it
would. Now hit return. The horizontal scroll nub appears and the view
is very wide.
If you skip the step of center aligning, it all works as expected.
Any thoughts?
Thanks,
Jeff Argast
P.S. This was all done on 10.3.2, XCode 1.1. I don't know what happens
on Jaguar.
_______________________________________________
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.