Clipboard.GetText() always returns empty string in Mono on Mac(Clipboard.GetText() 在 Mac 上的 Mono 中总是返回空字符串)
问题描述
有没有办法在不返回空字符串的 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 中总是返回空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Clipboard.GetText() 在 Mac 上的 Mono 中总是返回空字符串


- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 如何用自己压缩一个 IEnumerable 2022-01-01