• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Verification of a bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Verification of a bug


  • Subject: Re: Verification of a bug
  • From: Greg Titus <email@hidden>
  • Date: Wed, 27 Mar 2002 13:11:39 -0800

The document edited bug happens because NSTextView is cheating with the undo stack.

When you type, it checks to see if the top-most undo object in the stack is also a typing change from itself. If so, it doesn't add a new undo object. (It works this way so that you can type multiple keystrokes and undo them all as a single operation.)

The NSDocument architecture is looking for additions of new undo objects in order to mark the document as edited.

Now, the NSTextView WILL add a new undo object if you change the selection before starting to type again. (Which makes sense, the user likely thinks of this as two different typing operations which should be undone separately.)

So my suggestion is that on save, you simply call [myTextView setSelectedRange:[myTextView selectedRange]], and see if that resets the internal flag in NSTextView and causes a new undo operation to be pushed on the next time you type.

Hope this helps,
--Greg

On Wednesday, March 27, 2002, at 11:50 AM, Scott Anguish wrote:

this shouldn't be necessary, since this is already implemented (and works in almost all the other cases).. and it worked fine before the sheets UI was added.

also, TextEdit doesn't use the NSDocument code last time I checked...


On Wednesday, March 27, 2002, at 04:31 AM, Martin Kautz wrote:

guess you need to care about your doc's change state by yourself.

There's a good example in Apples TextEdit source...

<snip>
- (void)setDocumentEdited:(BOOL)flag {
if (flag != isDocumentEdited) {
isDocumentEdited = flag;
[[self window] setDocumentEdited:isDocumentEdited];
if (transientDocument == self) transientDocument = nil;
}
if (!isDocumentEdited) changeCount = 0;
}

- (BOOL)isDocumentEdited {
return isDocumentEdited;
}
</snip>
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Verification of a bug
      • From: Scott Anguish <email@hidden>
References: 
 >Re: Verification of a bug (From: Scott Anguish <email@hidden>)

  • Prev by Date: Re: Application icon
  • Next by Date: Re: NSNotifications inside NSThreads?
  • Previous by thread: Re: Verification of a bug
  • Next by thread: Re: Verification of a bug
  • Index(es):
    • Date
    • Thread