Questions tagged [nspasteboard]

NSPasteboard is the Cocoa class representation for clipboard data, allowing information to be copied and pasted within and between programs. NSPasteboards also represent information that is being dragged within or among programs.

161 questions
0
votes
0 answers

NSTableView: Implementing -pasteboardWriterForRow Prevents TextField Selection

Context I'm building a Mac app using Xcode 14 RC, Swift 5.7, with a base SDK of macOS 12 and a deployment target of macOS 11.0 In this app, I have a view-based NSTableView. The tableView is backed by an array of Foo objects, which look like…
Bryan
  • 4,628
  • 3
  • 36
  • 62
0
votes
0 answers

Snapping (constraining drag item's position) during NSDraggingSession

I am looking for a way how to constrain the NSDraggingItem position during dragging. I first checked if the enumerateDraggingItemsWithOptions: method could help. I tried to set the draggingFrame of each enumerated item to (my) snap position. It…
0
votes
0 answers

Why copy multiple file use AppleScript cannot paste to 3rd party application?

I cannot paste to application, but in finder it works fine. I also try use swift + NSPasteboard, seems to be the same problem. What do I need to do to make it work totally same like finder? Whether to use AppleScript or swift, I will take…
Zheng Xiaodong
  • 143
  • 3
  • 9
0
votes
2 answers

Swift ui xcode NSPasteboard empty

I have the following code at the beginning of the program, when it starts I need to see if there is any copied text. But if I start the program and no text has been copied at the moment, I get the following error. How can I solve the…
Paul
  • 3,644
  • 9
  • 47
  • 113
0
votes
0 answers

How to convert a keyedArchiver to a string and back again

I want to convert a custom object into a propertyList. Then later I want to retrieve it via NSOutlineView. I use a NSKeyedArchiver/unArchiver to convert my object to and from a NSData. In my custom object…
Carl Carlson
  • 500
  • 4
  • 17
0
votes
1 answer

Reorder and Move NSTableView Row with NSPasteboard

I have an NSTableView where I can drag and drop table rows to reorder them. This works by setting a drag type in my view controller: @IBOutlet weak var tableView: NSTableView! let dragType = NSPasteboard.PasteboardType(rawValue:…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
0
votes
0 answers

How can I accept Directories in a Drag and Drop zone?

Hello I've implemented multiple drag and drop areas in my app and by now everything worked fine because I only had to drop files of various types. Now I have a NSView where I need to drop only folders. I took the code from a tutorial where it…
Shoni Fari
  • 197
  • 8
0
votes
0 answers

How to copy item to finder clipboard with Swift on MacOS

I'm looking to perform copy/paste operations with Swift with audio clips on MacOS. This can be done using Finder by right clicking on an audio clip, selecting copy, and then pasting it. Currently, when an audio file is copied, it is sent to the…
0
votes
1 answer

Swift. How to allow dragging an URL from the browser to a NSView

I have an NSView that accepts dropped files and store their fileURLs but I'd like it to accept HTTP URLs dragged from an Internet Browser as well. I mean, the same behavior as dragging it to Finder to create a .webloc file but inside my app. What's…
rmvz3
  • 1,133
  • 2
  • 16
  • 27
0
votes
0 answers

Swift NSPasteboard to copy an audio (.wav) file to clipboard

I've been pulling my hair out trying to find any resources on to do thi. It seems to be possible according to the documentation. But nothing I try works. I only need to copy the audio to the clipboard, the application I'm writing requires that the…
Mike Land
  • 11
  • 2
0
votes
1 answer

How do I get a layer backed NSView to write to PDF in the clipboard

I am using a layer backed view with a CGImage and would like to use the NSView.writePDF(inside:to) API to copy the views image to the clipboard. The view has subviews that I would like included in the PDF. I have created a Xcode playground to…
Duncan Groenewald
  • 8,496
  • 6
  • 41
  • 76
0
votes
2 answers

Copy current selection on hotkey

I want to copy the current selection, even if it's in another application like Mail, when the user hits a specified hotkey like Cultured Code does it in Things when you create a new task. I got the hotkey working and I know how to place and get…
flohei
  • 5,248
  • 10
  • 36
  • 61
0
votes
0 answers

Objective-c: NSPasteboard: what's difference with - setData:forType:, - setString:forType: and - setPropertyList:forType:

i want to know what's difference with - setData:forType: - setPropertyList:forType: and - setString:forType: in NSPasteboard api? https://developer.apple.com/documentation/appkit/nspasteboard?language=objc when i notice the description of…
0
votes
1 answer

NSTextView modify string before pasting

My goal is to modify a string - remove all non-letters (numbers, whitespace, etc) - before pasting it in an NSTextView. Via this link, I came up with the following code: override func paste(_ sender: Any?) { let pasteboard =…
koen
  • 5,383
  • 7
  • 50
  • 89
0
votes
1 answer

Continuously calling [NSPasteboard canReadObjectForClasses:options:] causes memory bloat

I'm using the following simple Objective-C program to receive messages from another process and display alerts, using an NSPasteboard as the means of communication between the 2 processes. The program works for me, but I've observed that the program…
eckenrod
  • 519
  • 4
  • 17