I did not do this, so I only communicate with documents / knowledge.
Since you have access to the text view, you can become a textview delegate. Then you will receive helpful messages ...
Before changing the text:
- TextView: shouldChangeTextInRange: replacementString:
- TextView: shouldChangeTextInRanges: replacementStrings:
- TextView: shouldChangeTypingAttributes: toAttributes:
After changing the text:
- textViewDidChangeTypingAttributes:
I donβt know if you will receive these changes (UndoManager bypasses this stuff?), But you can. In any case, you can request selections when processing previous messages.
Before changing a selection:
- TextView: willChangeSelectionFromCharacterRange: toCharacterRange:
- TextView: willChangeSelectionFromCharacterRanges: toCharacterRanges:
After:
- textViewDidChangeSelection:
UndoManager should tell you that it is in the process of executing Undo, which means that you can distinguish between regular changes and undo-based changes.
It seems to be enough to continue, I hope this helps.
source share