×
Namespaces

Variants
Actions
Revision as of 08:57, 18 September 2012 by hamishwillee (Talk | contribs)

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

Formatting an input dialog to accept large string of only digits

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Compatibility
Platform(s): S60 1st Edition
S60 2nd Edition
S60 2nd Edition (initial release)
S60 1st Edition
Article
Keywords: CAknNumberQueryDialog
Created: User:Technical writer 2 (27 Mar 2003)
Last edited: hamishwillee (18 Sep 2012)

Contents

Overview

Formatting an input dialog to accept large string of only digits

Description

I want to prompt the user for a 15-digit serial number. I am currently using a CAknTextQueryDialog because CAknNumberQueryDialog only accepts an integer and would not handle enough digits.

I am happy to get the number supplied as a 15-character string but currently the CAknTextQueryDialog accepts all characters, which makes it much harder for the user to enter the serial number.

Is it possible to get an input dialog to accept a large string which is just digits?

Solution

It is possible to specify flags for the Edwin editor to restrict the acceptable input. The input dialog resource will look like this in a general case:

DLG_LINE
{
type=EEikCtEdwin;
id=EMyQuery;
control=EDWIN { maxlength=15; };
}

The editor customization inserted into the dialog’s PrepareLC() method:

void CTestDlgDialog::PrepareLC(TInt aResourceId)
{
CEikDialog::PrepareLC( aResourceId );
// Dialog base class can be CAknDialog
 
//CAknDialog::PrepareLC( aResourceId );
// Pick up the Editor control from the dialog
CEikEdwin* control = static_cast<CEikEdwin*>(ControlOrNull(EMyQuery));
// Set the input mode
control->SetAknEditorInputMode(EAknEditorNumericInputMode);
// Restrict the other input modes
control->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);
}

Summary

The previous example is a comfortable way to enter long numbers. However, it allows entering characters like "*#pw+", using the  '*' or '#' keys. This can be disabled by monitoring the key input or by displaying a note to the end user if the entered input contains more than just numbers.

This page was last modified on 18 September 2012, at 08:57.
64 page views in the last 30 days.