public static void CopyToClipboard(string text) { NSPasteboard clipboard = NSPasteboard.GeneralPasteboard; clipboard.ClearContents(); clipboard.WriteObjects(new NSString[] { (NSString)text }); }
internal static void Store(NSPasteboard pboard, object data, int id) { if (id == 0) { pboard.ClearContents(); managed.Clear(); providers.Clear(); return; } if (data == null) { return; } var name = DataFormats.GetFormat(id)?.Name ?? String.Empty; if (name == Clipboard.IDataObjectFormat) { managed[name] = data; var provider = new DataObjectProvider((IDataObject)data); var item = new NSPasteboardItem(); item.SetDataProviderForTypes(provider, provider.Types); pboard.WriteObject(item); providers.Add(provider); // Set flag that clipboard contains our data // Do it as the last step, to avoid fooling the FileMaker (and possibly other apps). pboard.SetStringForType(name, name); } }
public static void SetDataObject(object data, bool copy) { if (data is DataObject dataObject) { pasteboard.ClearContents(); foreach (var item in dataObject.Items) { switch (item.Data) { case string stringData: pasteboard.SetStringForType( stringData, item.Format); break; case bool boolItem: pasteboard.SetDataForType( NSData.FromArray(new byte[] { boolItem ? (byte)1 : (byte)0 }), item.Format); break; } } } }
/// <summary> /// Sets the clipboard. /// </summary> /// <returns>The clipboard.</returns> /// <param name="str">String.</param> public static void SetClipboard(string str) { NSString stri = (NSString)str; NSPasteboard pasteBoard = NSPasteboard.GeneralPasteboard; pasteBoard.ClearContents(); pasteBoard.WriteObjects(new INSPasteboardWriting [] { stri }); }
public void CopyToClipboard(NbtClipboardData data) { NbtClipboardDataMac dataItem = new NbtClipboardDataMac(data); NSPasteboard pasteboard = NSPasteboard.GeneralPasteboard; pasteboard.ClearContents(); pasteboard.WriteObjects(new NSPasteboardReading[] { dataItem }); }
public void WriteToPasteBoard(NSPasteboard pb) { // Copy data to the pasteboard pb.ClearContents(); pb.DeclareTypes(pboardTypes, null); pb.SetStringForType(mLetter, pboardTypes[0]); CGRect r = this.Bounds; NSData data = this.DataWithPdfInsideRect(r); pb.SetDataForType(data, pboardTypes[1]); }
private bool setToPasteboard(IntPtr handle) { if (handle == IntPtr.Zero) { return(false); } generalPasteboard.ClearContents(); generalPasteboard.WriteObjects(NSArray.ArrayWithObject(handle)); return(true); }
void InitPasteboard(NSPasteboard pb, TransferDataSource data) { pb.ClearContents(); foreach (var t in data.DataTypes) { if (t == TransferDataType.Text) { pb.AddTypes(new string[] { NSPasteboard.NSStringType }, null); pb.SetStringForType((string)data.GetValue(t), NSPasteboard.NSStringType); } } }
public override void SetText(string selectedText) { generalPasteboard.ClearContents(); generalPasteboard.WriteObjects(NSArray.ArrayWithObject(Cocoa.ToNSString(selectedText))); }
/// <summary> /// Prepares the pasteboard. /// </summary> /// <param name="pasteboard">The pasteboard to use.</param> /// <param name="dataType">The data type to put on the pasteboard.</param> /// <param name="data">The wrapped data to put onto the pasteboard.</param> public static void PreparePasteboard(NSPasteboard pasteboard, string dataType, NSDataWrapper data) { pasteboard.ClearContents(); pasteboard.SetDataForType(data, dataType); PasteboardHelperData[pasteboard] = data; }