A selection can range from a single character to the entire document. The following example code selects the first paragraph.
The current cursor position is the start of the document (position zero). Use CEditableText::ScanParas() with a mask of EScanToUnitEnd to find the document position of the end of the paragraph containing the cursor.
Use CTextView::SetDocPosL() to change the document position of the cursor to the end of the first paragraph. The second argument of ETrue causes the range of characters between the old and new cursor positions to be selected.
TInt pos=0; TUint scanMask=CPlainText::EScanToUnitEnd; iRichText->ScanParas(pos,scanMask); // get end pos of 1st para // move cursor to end of para and select it iTextView->SetDocPosL(pos,ETrue);
The use of SetDocPosL() demonstrated above shows how text can be selected using the old cursor position as the anchor . An alternative method of selecting text is to use CTextView::SetSelectionL() . This function allows the user to specify the anchor as well as the cursor position.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.