Re: enhancing NSTextView for optionally-hidden text
Re: enhancing NSTextView for optionally-hidden text
- Subject: Re: enhancing NSTextView for optionally-hidden text
- From: Quincey Morris <email@hidden>
- Date: Tue, 20 Nov 2012 23:26:07 -0800
On Nov 20, 2012, at 21:03 , Kurt Bigler <email@hidden> wrote:
> Given how this view is used, for appending only in the style of an uneditable text log permitting user selections and Copy, the easiest way I can think to implement it is to maintain two text views, one with hidden text included, and one without, and simply swap the two views to implement show/hide of hidden text.
>
> Is there a better way? I would rather not get deep into a highly-structured text document kind of model in order to achieve something like this (assuming that even helps).
Perhaps better than two views would be two attributed string properties (of the object that knows when the log changes). In one, you'd either mark the hideable text with the (unique?) attribute that indicates the hideability in the display, or with an custom attribute.
One string property would return the whole attributed string. The other would be a derived property that takes the whole string, and constructs a display string which in turn is either the same whole string (if hideable text is turned on) or a reduced string (if not, by enumerating the attributes). Assuming you took care to make the derived property KVO-compliant, then you could simply bind the text field to the derived property.
This may not sound like an improvement on your original idea, but it centralizes the necessary code (in the whole string setter, perhaps), and avoids the IB awkwardness of superimposed views.
_______________________________________________
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