Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

john903

macrumors member
Original poster
Apr 11, 2008
66
0
How do you copy and paste plain text into the pasteboard? I'm using Carbon. Any code examples would be appreciated.

Thanks!
 

john903

macrumors member
Original poster
Apr 11, 2008
66
0
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!
 

john903

macrumors member
Original poster
Apr 11, 2008
66
0
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.
 

john903

macrumors member
Original poster
Apr 11, 2008
66
0
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?

Code:
OSStatus err = noErr;
PasteboardRef inPasteboard;
PasteboardCreate(kPasteboardClipboard, &inPasteboard);
	
PasteboardSyncFlags syncFlags;
ItemCount itemCount;
	
syncFlags = PasteboardSynchronize( inPasteboard );
require_action( syncFlags&kPasteboardModified, PasteboardOutOfSync, err = badPasteboardSyncErr );
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.