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 中总是返回空字符串


基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01