Carbon - Pasteboard

Discussion in 'Mac Programming' started by john903, Apr 11, 2008.

  1. john903
    Expand Collapse
    macrumors member

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

    Thanks!
     
  2. john903
    Expand Collapse
    thread starter macrumors member

    Joined:
    Apr 11, 2008
    #3
    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!
     
  3. john903
    Expand Collapse
    thread starter macrumors member

    Joined:
    Apr 11, 2008
    #5
    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.
     
  4. krye
    Expand Collapse
    macrumors 68000

    krye

    Joined:
    Aug 21, 2007
    Location:
    USA
    #6
  5. john903
    Expand Collapse
    thread starter macrumors member

    Joined:
    Apr 11, 2008
    #7
    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 );
    
     
  6. john903
    Expand Collapse
    thread starter macrumors member

    Joined:
    Apr 11, 2008
    #8

Share This Page