1

I have an NSTextView/NSTextStorage combination and I want to track the 'modified' state of the text storage.

I could simply watch for changes to the text and update my 'modifiedDate' variable - problem is I need UNDO to work also - and UNDO should also undo the modifiedDate.

If I update my modifiedDate variable each time the text changes then it works - but UNDO on the TextView will be one character at a time (not desirable.)

I did try looking for undoManagerWillCloseUndoGroupNotification and updating my modifiedDate there, but I get the same effect (single character undo) I thought it might 'slip' the modifiedDate undo inside the TextView undo group - but it appears not.

This is either one of those things that just can't be done - or it's simple - can someone put me out of my misery?

Thanks

4

1 回答 1

0

“解决方案”是在收到 undoManagerDidOpenUndoGroupNotification 时记录我的 modifiedDate(第一响应者是我的 NSTextView)

其他需要注意的是拖放到 NSTextView (当它不是第一响应者时) - 在这种情况下,我发现在 readSelectionFromPasteboard 中将第一响应者设置为我的 NSTextView:覆盖我的 NSTextView 排序的东西。

于 2015-02-12T10:35:24.030 回答