This page was last modified 12:52, 8 December 2007.
Clipboard Copy/Cut/Paste
From Forum Nokia Wiki
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(); // CBPlainText 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(); // CBPlainText return CBPlainText; }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| E32User-Cbase 46 panic when terminating long running active object | delwynh | General Symbian C++ | 2 | 2003-09-01 22:15 |
| list box doesn't appear | marwa mohamed | Symbian User Interface | 1 | 2005-10-03 04:01 |
| Carbide Express 1.1, I can not compile project for ARM | golemur | Symbian Tools & SDKs | 13 | 2007-04-19 16:13 |
| 在 Vc6 中加入中文的問題 | lauyk001 | Symbian | 5 | 2005-07-16 05:00 |
| Carbide c++ License error. | max.brin | Carbide.c++ and CodeWarrior Tools | 2 | 2007-11-19 09:35 |
