Kyle, thanks for the help. That at least got my test app straightened out.
I have filed Bug ID# 7675789 (with the test app) on the fact that the bound
text does not update from programmatic insertions.

In the test app, I can simply update the bound value myself every time there
is a programmatic update.  Unfortunately, that workaround doesn't work in
the actual application because the relevant controller does not have access
to the bound value.  I am depending on the binding to properly update the
stored value deep in a data hierarchy.

BTW, in the actual app, the text view is constructed programmatically
because IB has no way to set up an NSTextView outside a scroller.  (Some of
us had that discussion here awhile back.)  I also had to set the binding
programmatically and set it to continuously update.


On 2/22/10 7:20 AM, "cocoa-dev-requ...@lists.apple.com"
<cocoa-dev-requ...@lists.apple.com> wrote:

> Well, I was going to argue with you, but your post triggered further
> investigation.  I realized that in the past, I had constructed my own.
> Somehow, in this case, I got it in my head that the bindings would make the
> text view use my NSTextStorage.  Duh.  So I changed to the following in the
> test app:
> 
> @interface MyDocument : NSDocument
> {
>     IBOutlet NSTextView* tv;
>     NSAttributedString* ts;
> }
> @property(copy) NSAttributedString* ts;
> - (IBAction)insertSomething:(id)sender;
> @end
> 
> - (IBAction)insertSomething:(id)sender {
>     NSUInteger index = [tv selectedRange].location;
>     NSTextStorage* vtc = [tv textStorage];
>     [vtc beginEditing];
>     [vtc insertAttributedString:[[NSAttributedString alloc]
> initWithString:@"XYZ"] atIndex:index];
>     [vtc endEditing];
> }
> 
> At least now, I'm dinging the right text storage and the insertion works.
> However, it does confirm my original problem, i.e., that the programmatic
> edit does not show up in the bound NSAttributedString unless there is an
> additional text-entry edit.  Now I'm thinking bug report, unless there is
> something else I can do to trigger the KVO for programmatic edits.
> 
> I suppose a workaround could be to set up a dummy ivar and a dependency to
> make it update.
> 
> On 2/21/10 7:24 PM, "Kyle Sluder" <kyle.slu...@gmail.com> wrote:
> 
>> On Sun, Feb 21, 2010 at 2:00 PM, Gordon Apple <g...@ed4u.com> wrote:
>>> This is getting stranger by the minute.  I ruled out the menu issue as the
>>> cause, then created a test app from the standard doc template.  Window
>>> contain a scrolling text view and a button.  The app edits and archives
>>> correctly (compiled using GC).  "init" sets an initial string in ts.  The
>>> text view is bound to ts.
>> 
>> You need to post the code that sets up the text system. Unless you
>> actually meant "bound" in the sense of Cocoa Bindings, in which case
>> none of this is ever going to work because then the text view will
>> operate on a copy of the text storage you've provided. The only way to
>> get the text view to use your text storage is to set it up yourself.
>> 
>> --Kyle Sluder

-- 
Gordon Apple
Ed4U
Little Rock, AR


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to