Clipboard.GetText() 在 Mac 上的 Mono 中总是返回空字符串

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)