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.
Handle edwin events
The following example shows how to handle edwin event primarily a text update. There are lot of times when we want to restrict what goes into the edwin such as only numbers, and nothing else.
Header file required:
Add following lines in .rssi file.
RESOURCE EDWIN r_your_edwin
maxlength = 511;
default_case = EAknEditorTextCase;
allowed_case_modes = EAknEditorAllCaseModes;
numeric_keymap = EAknEditorStandardNumberModeKeymap;
default_input_mode = EAknEditorTextInputMode;
allowed_input_modes = EAknEditorAllInputModes;
special_character_table = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG;
Add following lines in .h file.
class CYourContainer : public CCoeControl, public MEikEdwinObserver
void HandleEdwinEventL(CEikEdwin *aEdwin, TEdwinEvent aEventType);
Add following lines in .cpp file.
//In your container class
CEikEdwin* yourEdwin = new (ELeave)CEikEdwin;
yourEdwin->SetEdwinObserver(this); //to ensure you get callbacks when anything happens in the edwin
// Create a resource reader that we'll use to get the settings
CleanupStack::PopAndDestroy(); // reader
// Implement the HandleEdwinEventL in your container class
void CYourContainer::HandleEdwinEventL(CEikEdwin *aEdwin, TEdwinEvent aEventType)
if (aEventType == EEventTextUpdate)
TBool needReDraw = EFalse;
for (TInt i = buf16.Length()-1; i > -1; i--)
needReDraw = ETrue;
if (needReDraw )
In case of a CEikRichTextEditor, calling the SetTextL directly would result in a ETEXT 12 or a EIKCOCTL 70 panic, to avoid that modify the code a little bit in the HandleEdwinEventL above, in case of a text change needed(needReDraw is ETrue) like this.
CEikRichTextEditor* editor = static_cast< CEikRichTextEditor* >(aEdwin);
CRichText* richText = editor->RichText();
richText->InsertL(0, buf16); // insert starting from 0 pos
//aEdwin->SetTextL(&buf16); // This causes the EText12 or EIKCOCTL 70 panics
Now when the HandleEdwinEvent function gets called the aEdwin would point to yourEdwin created earlier, and if there is a text inputted by the user, it would check if whats entered is not digit, it would keep removing them. Thereby ensuring that you have only digits in the edwin.
Added by - Mayank on 12/05/2009