简体   繁体   中英

NSPasteboard in Xamarin.Mac

I am trying to get string from NSPasteboard in Xamarin.Mac, here is my code

   NSPasteboard pasteboard = NSPasteboard.GeneralPasteboard;
   string text = "";

Then what method of pasteboard do I use to store the string into text?

If you know you have string-based data on the pasteboard, you can use GetStringForType using the type of NSStringType .

Example:

string text = NSPasteboard.GeneralPasteboard.GetStringForType(NSPasteboard.NSStringType);

Returns a concatenation of the strings for the specified type from all the items in the receiver that contain the type.

Otherwise you can cycle through all the items on in the pasteboard using PasteboardItems to return an array of NSPasteboardItem and review each item for the type that you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM