Re: Questions on using a NSTextView as a source viewer.
Re: Questions on using a NSTextView as a source viewer.
- Subject: Re: Questions on using a NSTextView as a source viewer.
- From: Ken Thomases <email@hidden>
- Date: Fri, 10 Oct 2014 00:58:00 -0500
On Oct 10, 2014, at 12:02 AM, Daryle Walker <email@hidden> wrote:
> On Oct 7, 2014, at 8:03 PM, Ken Thomases <email@hidden> wrote:
>
>> On Oct 7, 2014, at 5:29 PM, Daryle Walker <email@hidden> wrote:
>>
>>> 1. Although the text in the window expands vertically as needed, it never does horizontally. Wrapping always happens when lines are too long, but it adjusts as the width of the window is changed. How do I get “infinite” space horizontally? I tried various tweaks in Interface Builder and looked at various Apple guides, but I can’t turn off the horizontal wrapping.
>>
>> On the Size inspector of IB, enable Resizable Horizontally. Then, in code, do this (assuming self.textView is the outlet property):
>>
>> self.textView.textContainer.widthTracksTextView = NO;
>>
>> I couldn't find anyplace in IB that exposes the text container attributes.
>
> I added “textContainer.widthTracksTextView” to the run-time attributes section in Interface Builder as a Boolean, and it changes the behavior in the other direction; the text wraps at the window’s original width, even if I make the window wider. Changing it to YES (i.e. turning on the checkbox) brings back the previous behavior. (I first changed the horizontal point limit to 10K, just like the vertical limit.)
Did you also set Resizable Horizontally (the first step, above)? And, yes, good catch: I forget to mention changing the max. width.
I tested this and it worked for me. In summary, all three steps:
* Set the text view's max. width
* Set the text view to be horizontally resizable
* Set textView.textContainer.widthTracksTextView = NO
> On Oct 7, 2014, at 5:33 PM, Daryle Walker <email@hidden> wrote:
>>
>>> 3. The text in the view-source window is editable, although I turned that off. (It’s still selectable.) I can cut/copy/paste. Isn’t turning off editing supposed to stop this?
>>
>> Are you using bindings? Do any of them have Conditionally Sets Editable enabled in the binding options?
>
> Yes, one for the text view's contents, and another on the window's title (using the format substitution version). There is a binding for the text view being editable, but I’m not using it. (The text contents property in my window controller class is read-write.)
My point was to check the options on those bindings for the Conditionally Sets Editable option. If any of them have that option enabled, that would explain why your text is editable when you set the text view to non-editable. The binding option is overriding the attribute you set. Turn it off.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden