jbr*_*nan 3 macos cocoa nstextview
我有一个NSTextView,我收到-textDidChange:通知.从那里,我可以得到整个textview的当前字符串值,但我无法弄清楚如何分辨已删除和添加的内容.
例如,如果文本视图中的字符串是This is a string并且用户删除了该字符串,那么g如何才能知道该更改?
有没有办法实现这一点,最好没有子类化?
有几种委托方法应该可以满足您的需求:
– textView:shouldChangeTextInRange:replacementString:
– textView:shouldChangeTextInRanges:replacementStrings:
– textView:shouldChangeTypingAttributes:toAttributes:
– textViewDidChangeTypingAttributes:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1230 次 |
| 最近记录: |