问题描述
有没有办法在不返回空字符串的 Mono 中获取 Mac 上的剪贴板?这是使用最新的非测试版单声道.
Is there a way to get the clipboard on a Mac in Mono that doesn't return an empty string? This is using the latest NON-beta version of mono.
Clipboard.SetText(String) 工作正常,我可以粘贴到其他程序.
Clipboard.SetText(String) works fine and I can paste to other programs.
Clipboard.GetText(TextDataFormat.UnicodeText)
Clipboard.GetText(TextDataFormat.Text)
Clipboard.GetText(TextDataFormat.Rtf)
即使 Clipboard.ContainsText(TextDataFormat.UnicodeText) 返回 true,也会返回 "".
All return "" even though Clipboard.ContainsText(TextDataFormat.UnicodeText) returns true.
解决方案最终是在 mac 上使用 NSPasteboard.https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html
The solution ended up being to use NSPasteboard on mac. https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html
推荐答案
最终解决方案是在 mac 上使用 NSPasteboard.https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html
The solution ended up being to use NSPasteboard on mac. https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html
我无法让剪贴板返回任何内容.Mono 在 NSPasteboard 周围有包装器,所以最终以这种方式非常简单.
I could not ever get Clipboard to return anything. Mono has wrappers around NSPasteboard so it ended up being pretty easy this way.
这篇关于Clipboard.GetText() 在 Mac 上的 Mono 中总是返回空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!