nspasteboard

How does right-clicking text and selecting a service work?

…衆ロ難τιáo~ 提交于 2020-01-06 02:28:05
问题 [1] When I select and right-click any text in any app, I get a Services menu where I can click to invoke any service like Search With Google . After clicking, a NSPasteboard object is automatically sent to the service containing the selected text. [2] 3rd party apps can use the BOOL NSPerformService ( NSString *itemName, NSPasteboard *pboard ) function to programatically invoke any service. Here the app has to set the NSPasteboard object, which is sent to the service. Is there a way to

Dragging files into other applications in cocoa OSX

╄→尐↘猪︶ㄣ 提交于 2020-01-05 05:37:06
问题 I'm trying to convert a windows application into OSX, everything is working now, except this small feature, the drag&drop of files from my app into any other window that supports drops. Receiving drops it's easy, the problem is being the source of the data to drag. My application only has 1 window with 1 view, I draw every control myself in there. So I simply extended my view like this @interface NativeView : NSView <NSDraggingSource, NSPasteboardItemDataProvider> . Now the resto of the code

Determine the source application of current pasteboard content

不问归期 提交于 2019-12-22 05:45:12
问题 Several OSX clipboard managers from AppStore show the ability to determine the source-application of content that was copied to the clipboard. I am writing some simple clipboard observer and would like to show the source-application icon near the content, stored in general NSPasteboard. And I would like to know how this can be achieved. As far as I can see, NSPasteboard doesn't provide any additional info except types of data and data itself. Maybe there are some events or notifications to

How do I handle multiple file drag/drop from Finder in Mac OS X 10.5?

南楼画角 提交于 2019-12-21 04:05:03
问题 I need to get the URLs of all files dragged/dropped into my application from Finder. I have a Cocoa app running on 10.6 which does this by using the new 10.6 NSPasteboard APIs which handle multiple items on the pasteboard. I'm trying to backport this app to 10.5. How do I handle this on 10.5? If I do something like below, I only get the first URL: NSArray *pasteTypes = [NSArray arrayWithObjects: NSURLPboardType, nil]; NSString *bestType = [pboard availableTypeFromArray:pasteTypes]; if

Can I receive a callback whenever an NSPasteboard is written to?

a 夏天 提交于 2019-12-17 10:22:21
问题 I've read Apple's Pasteboard Programming Guide, but it doesn't answer a particular question I have. I'm trying to write a Cocoa application (for OS X, not iOS) that will keep track of everything that is written to the general pasteboard (so, whenever any application copies and pastes, but not, say, drags-and-drops, which also makes use of NSPasteboard). I could (almost) accomplish this by basically polling the general pasteboard on a background thread constantly, and checking changeCount. Of

Cut & paste of files with NSPasteboard

心不动则不痛 提交于 2019-12-13 04:16:30
问题 How are we supposed to cut & paste files using NSPasteboard ? Currently I implemented copy and paste by writing and reading file URLs. The problem with cut is, that after I wrote the URL to the pasteboard, I have to remove the file. And when I try to paste the file it doesn't exist anymore and I can't copy it. Should I write something else onto the pasteboard? I also thought about copying the file to a temporary hidden location, but that seems to be a bit inefficient. Is there any other

Mac Listen for event: Copy to Pasteboard

老子叫甜甜 提交于 2019-12-12 01:03:06
问题 I was reading NSPasteboard, then wanted to find.... I am trying to find the correct Notification method that listens to the copy event of data to the clipboard. Also I am trying to find file path of the data that is copied to the clipboard. Which would be a pasteboard object. If I copy text from a page in the browser, I am trying to find out how to grab the url address of the page the text was copied from. Any ideas? 回答1: No notification available. Devara Gudda is right. You request info from

Dissociating NSPasteboardItem from pasteboard

女生的网名这么多〃 提交于 2019-12-11 03:32:35
问题 What I am trying to do on a high level is store the current data that is on the pasteboard (data of any type) using this code, which I believe to be correct: - (NSArray *)readFromPasteBoard { NSMutableArray *pasteboardItems = [NSMutableArray array]; for (NSPasteboardItem *item in [pasteboard pasteboardItems]) { //Create new data holder NSPasteboardItem *dataHolder = [[NSPasteboardItem alloc] init]; //For each type in the pasteboard's items for (NSString *type in [item types]) { //Get each