nspasteboard

NSPasteboard and simple custom data

蓝咒 提交于 2019-11-30 06:25:27
问题 I'm having a really difficult time trying to get NSPasteboard to work, so forgive me for my lack of understanding. All I want is a simple way to write and retrieve from the pasteboard a NSUInteger value that is only for my application. All I am doing is drag dropping an item within my application, so all I need in the pasteboard is the item's id. I have tried looking into NSPasteboardItemDataProvider and NSPasteboardItem, and NSData, but they all have convoluted way of doing something so

How to paste text from one app to another using Cocoa?

拟墨画扇 提交于 2019-11-29 14:52:11
问题 I have read about NSPasteBoard in the Apple documentation, and how it allows for applications to write into the PasteBoard and allow other applications to read that text and use it. Could someone tell me how to paste text from am application (that sits in the status bar) into a NSTextField that is inside a different application. What I am trying to do is something similar what Snippet and SnippetsApp do. If I am completely stupid and missed the obvious in Apple Docs, could you please point me

NSPasteboard and simple custom data

流过昼夜 提交于 2019-11-28 18:24:20
I'm having a really difficult time trying to get NSPasteboard to work, so forgive me for my lack of understanding. All I want is a simple way to write and retrieve from the pasteboard a NSUInteger value that is only for my application. All I am doing is drag dropping an item within my application, so all I need in the pasteboard is the item's id. I have tried looking into NSPasteboardItemDataProvider and NSPasteboardItem, and NSData, but they all have convoluted way of doing something so simple. Infact, I have no idea what is the correct way of doing something so simple - every sample around

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

时光总嘲笑我的痴心妄想 提交于 2019-11-27 11:13:13
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 course, doing this would make me feel very dirty on the inside. My question is, is there a way to ask