Contents |
This control supports editing a single floating point value. The maximum and minimum numbers which can be entered into the editor may be set. Values outside these bounds are invalid, and a warning is given when an attempt is made to remove the focus. The class also specifies the maximum length of the editor, in characters. This class is not intended for user derivation.
To create a CEikFloatingPointEditor control you need to instantiate it from a resource Or you can instantiate it directly, specifying all parameter in constructL().
CEikFloatingPointEditor* iInputbox;
// Instantiate the control
iInputbox = new (ELeave)CEikFloatingPointEditor;
iInputbox->ConstructL(0.0,9999999.99,10); //respective parameter are minimum number, maximum number and text limit.
iInputbox->SetContainerWindowL(*this);
iInputbox->SetObserver(this);
//need to set focus to editor, else it will not get input.
iInputbox->SetFocus(ETrue);
//change backgroung of color
iInputbox->SetBackgroundColorL(TRgb(3,4,5));
//set editor case
iInputbox->SetAknEditorCase(EAknEditorTextCase);
iInputbox->SetAknEditorPermittedCaseModes(EAknEditorAllCaseModes);
//set allowed input mode
iInputbox->SetAknEditorInputMode(EAknEditorNumericInputMode);
iInputbox->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);
//make T9 off.
iInputbox->SetAknEditorFlags(EAknEditorFlagNoT9);
Usually you'll want to set the text displayed on the control. This can be done by using the SetTextL() method. If you want to set the cursor position, you can call the SetCursorPosL() method. You can also set text by pressing keys.
iInputbox->SetTextL(text);
// Set the cursor to the beginning of the text and not do any selecting
iInputbox->SetCursorPosL(0, EFalse);
If you want to retrieve the text that's written in the editor, you can get it as HBufC* or copy the text to a descriptor. Usually it's easier to get it as HBufC since you don't have to worry about how much space you need. but keep in mind that GetTextInHBufL return NULL if no data is entered.
HBufC *text = NULL;
text = iInputbox->GetTextInHBufL();
if ((text != NULL) && (text->Length() > 0))
{
// There is some text, do what you want with it
}
// Don't forget to delete the object afterward!
delete text;