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.

Plain-text editor in Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

This code snippet shows how to create plain text editor in Symbian C++.

Article Metadata
Article
Created: Kavit Patel (12 Feb 2008)
Last edited: lpvalente (15 Aug 2014)

Create text resource in rss file

First create text resource in .rss file with attributes. For that we have to create an EDWIN resource as showing follow code.

#define KWidth 150
#define KLines 5
#define KMaxLength 256
 
RESOURCE EDWIN r_plaintexteditor_editor
{
width = KWidth;
lines = KLines;
maxlength = KMaxLength;
flags = EEikEdwinWidthInPixels;
avkon_flags = EAknEditorFlagNoT9;
default_case = EAknEditorLowerCase;
allowed_case_modes = EAknEditorUpperCase | EAknEditorLowerCase;
allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode;
default_input_mode = EAknEditorTextInputMode;
special_character_table = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG;
}

The attributes are self documenting: width, lines, flags and maxlength are implemented by Symbian OS while others are extensions defined by S60. There are also some S60-specific values defined for flags — these all contain the word "Akn" in their name. For example EAknEditorFlagEnableScrollBars

  • default_input_mode: defines the default input mode that is either char or number input
  • allowed_input_modes: defines the mode to be inputted.
  • special_character_table: defines the table for special characters to be inserted.
    • R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG is the default. Others are:
      • R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG for URL addresses.
      • R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG for E-mail addresses.
      • R_AVKON_CURRENCY_NAME_SPECIAL_CHARACTER_TABLE_DIALOG for Currency.

Create resource in view

The second step is to create resource in view or container's ConstructL() to display it.

We can do this as follows:

void CPlainTextEditorContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iEditor = new (ELeave) CEikEdwin;
iEditor->SetContainerWindowL(*this);
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_PLAINTEXTEDITOR_EDITOR);
iEditor->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(); // reader
iEditor->SetFocus(ETrue);
SetRect(aRect);
ActivateL();
}

Here iEditor is defined as CEikEdwin* iEditor; in CPlainTextEditorContainer.h

Handling Key Events

The next step is to handle key event. For that we have to override the OfferKeyEventL() method as follows:

TKeyResponse CPlainTextEditorContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
 
{
if (iEditor)
{
return iEditor->OfferKeyEventL(aKeyEvent, aType);
}
else
{
return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
}
}
This page was last modified on 15 August 2014, at 23:53.
96 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.

×