强制从 Cocoa WebView 进行纯文本复制
我有一个 Cocoa Webview 子类,我需要将从它复制的所有文本都变成纯文本。我尝试过覆盖 -copy 和 -pasteboardTypesForSelection,但没有运气,并且调试代码似乎表明这些方法从未被调用。我还尝试在 css 中将 -webkit-user-modify 设置为 read-write-plaintext-only (这在这种情况下也有效),但这似乎没有效果。
有什么想法吗?
I have a Cocoa Webview subclass, and I need to make all text copied from it be plaintext only. I have tried overriding -copy and -pasteboardTypesForSelection, but no luck, and debugging code seems to indicate that those methods are never called. I've also tried setting -webkit-user-modify to read-write-plaintext-only in the css (this would also work in this situation) but that seemed to have no effect.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,这似乎可行(使用子类实例作为其自己的编辑委托):
不确定这是否是最好的方法。
Okay this seems to work (with the subclass instance as its own editing delegate):
Not sure if this is the best way.