Secret Editors

You can use secret editors to securely obtain PINs or passwords from a user. As the user types into a secret editor, it represents each character with an asterisk on the display, as shown in Figure 8-10.

Figure 8-10. A secret editor in a form.

Series 60 provides two types of secret editor: a numeric one that can be used for PINs, and an alphanumeric one that can be used for passwords. Unlike the numeric secret editor, the alphanumeric one displays the character briefly before converting it into an asterisk. This is because in alphanumeric mode, each key on the keypad can produce different characters .

Using a Secret Editor

The code for using secret editors is quite simple and so does not require a dedicated example. This section shows how to define a secret editor in a resource, instantiate it and get and set its value.

Defining a Secret Editor in a Resource

Numeric secret editors are defined using a NUMSECRETED resource structure, and alphanumeric secret editors are defined using a SECRETED structure:

 RESOURCE NUMSECRETED r_my_numeric_secret_editor    {    num_code_chars = 4;    } RESOURCE SECRETED r_my_secret_editor    {    num_letters = 10;    } 

Each resource has a field representing the maximum length of the editor. In the NUMSECRETED resource, this is the num_code_chars field, and in the SECRETED resource, the num_letters field. The value must be less than a predefined constant, EMaxSecEdLength , otherwise the editor will panic on construction with the error code EEikPanicSecretEditorTooLong.

Instantiating a Secret Editor

Secret editors can be instantiated using any of the standard methods previously seen ”for example, using ConstructFromResourceL() , or creating one as part of a dialog, in which case the dialog constructs, and owns the editor.

Table 8-13. Secret Editor Resource and Classes

Secret Editor












The alphanumeric secret editor class is CEikSecretEditor and the numeric secret editor class is CAknNumericSecretEditor , which is derived from CEikSecretEditor . Table 8-13 summarizes the values that you should use for each type of secret editor resource, including the control value that you should use to create the editor in a dialog.

Getting and Setting a Secret Editor s Value

Once constructed , you can simply get a reference to the editor's text using GetText() and initialize the contents of the editor with SetText() .

Developing Series 60 Applications. A Guide for Symbian OS C++ Developers
Developing Series 60 Applications: A Guide for Symbian OS C++ Developers: A Guide for Symbian OS C++ Developers
ISBN: 0321227220
EAN: 2147483647
Year: 2003
Pages: 139 © 2008-2017.
If you may any questions please contact us: