PDA

View Full Version : Carbon - Pasteboard




john903
Apr 11, 2008, 06:22 PM
How do you copy and paste plain text into the pasteboard? I'm using Carbon. Any code examples would be appreciated.

Thanks!



kainjow
Apr 12, 2008, 08:35 AM
Apple has plenty of documentation on this:

http://developer.apple.com/documentation/Carbon/Conceptual/Pasteboard_Prog_Guide/paste_intro/chapter_1_section_1.html

john903
Apr 24, 2008, 08:22 PM
Yes, but I'm just looking for some sample code and the api looks like a lot to wade though. I just need two simple functions to put and get text from the pasteboard. I would greatly appreciate any code!

Thanks!

lee1210
Apr 24, 2008, 08:26 PM
http://developer.apple.com/samplecode/PasteboardPeeker/index.html#//apple_ref/doc/uid/DTS10000672

john903
Apr 24, 2008, 10:47 PM
I've seen that one. I'm new to Mac programming and the code is very dense for me. I'm working on a cross-platform project that uses GLUT but I still need to do a few OS specific things like copy and paste text. It was easy to implement in Windows but it's eluding me on Mac... Thanks for the help.

krye
Apr 25, 2008, 08:22 AM
Apple has plenty of documentation on this:

http://developer.apple.com/documentation/Carbon/Conceptual/Pasteboard_Prog_Guide/paste_intro/chapter_1_section_1.html

BABY RUTH!!!! Sorry. I saw the picture of Sloth and I couldn't help it.

john903
Apr 28, 2008, 05:45 PM
I got the first part working so I am able to copy text into the pasteboard.

I can't get my code working where I retrieve the text from the pasteboard. Here is the first part of the code. It fails at PasteboardSynchronize giving me the PasteboardOutOfSync error. Do I need to get a reference to the pasteboard some other way when retrieving text from the pasteboard?


OSStatus err = noErr;
PasteboardRef inPasteboard;
PasteboardCreate(kPasteboardClipboard, &inPasteboard);

PasteboardSyncFlags syncFlags;
ItemCount itemCount;

syncFlags = PasteboardSynchronize( inPasteboard );
require_action( syncFlags&kPasteboardModified, PasteboardOutOfSync, err = badPasteboardSyncErr );

john903
Apr 28, 2008, 06:56 PM
Ok, I just commented out the PasteboardSynchronize and it works. I got the code here so I guess if you are using this code outside of an event you don't need that call.
http://developer.apple.com/documentation/Carbon/Conceptual/Pasteboard_Prog_Guide/paste_tasks/chapter_3_section_6.html