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. Thanks for all your past and future contributions.

Revision as of 04:40, 1 August 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Retrieving the content of RichTextEditor at the tapped position on 5th Edition devices

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Platform(s): S60 5th Edition
S60 5th Edition
Keywords: HandlePointerEventL, CEikRichTextEditor
Created: User:TechnicalWriter2 (23 Jun 2009)
Last edited: hamishwillee (01 Aug 2012)



This article explains how to retrieve the content of RichTextEditor at the tapped position.


As S60 5th Edition devices are touch sensitive, the pointer events can be captured using HandlePointerEventL(). This is also used to handle such events as pointer down/up and dragging. Thus a class derived from CCoeControl can implement the HandlePointerEventL() function for customising the handling of pointer events.

In order to get the contents of the Editor, first we need to get the co-ordinates of the tapped event and then identify the document position of the nearest character edge to the window coordinates specified. This helps in retrieving the content (entire word) nearest to the tapped position.


Headers Required

#include <FRMTVIEW.H> 
#include <TXTRICH.H>


LIBRARY etext.lib
LIBRARY form.lib

The following code snippet enables the retrieving of the contents of the editor at the tapped position. This has to be used in HandlePointerEentL().

  TPoint tapPoint( aPointerEvent.iPosition );
//iEditor is a CEikRichTextEditor object
CTextView* iTextView = iEditor->TextView();
//Get the current document position based on the point where the stylus is tapped.
TInt docPos(iTextView->XyPosToDocPosL( tapPoint ) );
TInt start( 0 );
TInt length( 0 );
//By passing the current position of the document you can get the word information
//(the start position and the length)
iEditor->RichText()->GetWordInfo(docPos,start,length, EFalse, EFalse);
if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
// Based on the start position and the length get the word information.
// using the method Mid(TInt aPos, TInt aLength) const;
// the word at the tapped position can also be modifed

The above code snippet can also be used for highlighted items like URLs, phone numbers, and HTTP addresses. The Item Finder API can be used for highlighting URLs, phone numbers, and HTTP addresses.

In order to identify whether the stylus is tapped on the tag or not, the method CursorOverTag() can be used. The method returns a boolean value besides giving the start position and the length of the tag.

TBool iFlag = iEditor->RichText()->CursorOverTag( docPos, parser, start, length );

Related Links

For information on the Item Finder API, see the following link: Item Finder API

This page was last modified on 1 August 2012, at 04:40.
22 page views in the last 30 days.