Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Clipboard Copy/Cut/Paste

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: symbianyucca (30 Mar 2007)
Last edited: hamishwillee (20 Jul 2012)
Reviewer Approved    Thumbs up icon sm.jpg

You can use the clipboard directly with a CEikEdwin derived editor by first letting the user set a selection or setting the selection by using the SetSelectionL()method. Then to use the clipboard CEikEdwin implements the ClipboardL() method. To cut the selection to the clipboard use CEikEdwin::ECut as argument for the function, CEikEdwin::ECopy for copying and CEikEdwin::EPaste for pasting the text to the currently selected location.

To set text to the clipboard without using CEikEdwin you can use the following code:

void SetTextToClipBoardL(const TDesC& aText)
{
CClipboard* cb =
CClipboard::NewForWritingLC(CCoeEnv::Static()->FsSession());
 
cb->StreamDictionary().At(KClipboardUidTypePlainText);
 
CPlainText* BPlainText = CPlainText::NewL();
CleanupStack::PushL(BPlainText);
 
BPlainText->InsertL(0,aText);
 
BPlainText->CopyToStoreL(cb->Store(), cb->StreamDictionary(), 0,
BPlainText->DocumentLength());
 
CleanupStack::PopAndDestroy(); // BPlainText
cb->CommitL();
CleanupStack::PopAndDestroy(); // cb
}

And to get text from the clipboard you could utilize following example code:

CPlainText* GetTextFromClipBoardL(void)
{
CPlainText* BPlainText = CPlainText::NewL();
CleanupStack::PushL(BPlainText);
 
CClipboard* cb =
CClipboard::NewForReadingL(CCoeEnv::Static()->FsSession());
CleanupStack::PushL(cb);
cb->StreamDictionary().At(KClipboardUidTypePlainText);
 
BPlainText->PasteFromStoreL(cb->Store(), cb->StreamDictionary(), 0);
 
// the text is now inside the BPlainText
 
cb->CommitL();
CleanupStack::PopAndDestroy(); // cb
 
CleanupStack::Pop(); // BPlainText
return BPlainText;
}
This page was last modified on 20 July 2012, at 09:48.
90 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×