66
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Base class for TextField and TextBox
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <eikenv.h>
|
|
20 |
#include <eikappui.h>
|
|
21 |
#include <coecntrl.h>
|
|
22 |
// macros for resources
|
|
23 |
#include <EIKCOCTL.rsg>
|
|
24 |
|
|
25 |
#include <AknUtils.h>
|
|
26 |
// usied for playing error sounds when text input
|
|
27 |
#include <aknsoundsystem.h>
|
|
28 |
#include <aknenv.h>
|
|
29 |
// CAknSettingCache used for obtaining input language
|
|
30 |
#include <AknSettingCache.h>
|
|
31 |
#include <AknIndicatorContainer.h>
|
|
32 |
#include <aknEditStateIndicator.h>
|
|
33 |
|
|
34 |
#include <applayout.cdl.h> // LAF
|
|
35 |
#include <aknlayoutscalable_apps.cdl.h> // LAF
|
|
36 |
#include <aknlayoutscalable_avkon.cdl.h> // LAF
|
|
37 |
#include <AknLayoutFont.h>
|
|
38 |
// CAknExtendedInputCapabilities for extended input capabilities
|
|
39 |
#include <aknextendedinputcapabilities.h>
|
|
40 |
|
|
41 |
#include <lcdui.rsg>
|
|
42 |
// Avkon dialog for info notes
|
|
43 |
#include <aknnotewrappers.h>
|
|
44 |
|
|
45 |
// for fetching contacts from phonebook
|
|
46 |
// CPbk2StoreConfiguration for contact manager
|
|
47 |
#include <CPbk2StoreConfiguration.h>
|
|
48 |
// used in CMIDAiwPbk2Client::VPbkSingleContactOperationComplete to retrieving single contact
|
|
49 |
#include <MVPbkStoreContact.h>
|
|
50 |
// MVPbkContactLinkArray* iFetchedLinks
|
|
51 |
#include <CVPbkContactLinkArray.h>
|
|
52 |
// used in CMIDAiwPbk2Client::VPbkSingleContactOperationComplete
|
|
53 |
#include <MVPbkContactFieldTextData.h>
|
|
54 |
// used for open all contact stores
|
|
55 |
#include <MVPbkContactStoreList.h>
|
|
56 |
// API for iContactManager
|
|
57 |
#include <CVPbkContactManager.h>
|
|
58 |
|
|
59 |
// aiw used to invoke phonebook
|
|
60 |
#include <AiwContactSelectionDataTypes.h>
|
|
61 |
|
|
62 |
// phone client API classes for starting phone call
|
|
63 |
#include <AiwCommon.h>
|
|
64 |
#include <aiwdialdata.h>
|
|
65 |
// using AIWDialDataExt::KMaximumPhoneNumberLength
|
|
66 |
#include <aiwdialdataext.h>
|
|
67 |
|
|
68 |
// loading string from resource
|
|
69 |
#include <StringLoader.h>
|
|
70 |
|
|
71 |
// FEP CR
|
|
72 |
// constants for FEP
|
|
73 |
#include <AknFepInternalCRKeys.h>
|
|
74 |
#include <centralrepository.h>
|
|
75 |
|
|
76 |
#include <j2me/jdebug.h>
|
|
77 |
|
|
78 |
#include "CMIDEdwin.h"
|
|
79 |
#include "CMIDTextFieldItem.h"
|
|
80 |
#include "CMIDComponentFactory.h"
|
|
81 |
#include "CMIDUtils.h"
|
|
82 |
#include "CMIDUIManager.h"
|
|
83 |
|
|
84 |
#undef TRAP_INSTRUMENTATION_LEAVE
|
|
85 |
#define TRAP_INSTRUMENTATION_LEAVE(aResult) DEBUG_INT2("In CMIDEdwin.cpp, trapped method was called at line %D and got exception %D", __LINE__, aResult);
|
|
86 |
|
|
87 |
// class CMIDEdwin
|
|
88 |
|
|
89 |
void CMIDEdwin::ConstructL(const TDesC& aText,TInt aMaxSize)
|
|
90 |
{
|
|
91 |
|
|
92 |
// Set decimal separator according to the current locale.
|
|
93 |
// Note: decimal separators other than ',' and '.' are currently not supported
|
|
94 |
TLocale loc;
|
|
95 |
iDecimalSeparator = loc.DecimalSeparator();
|
|
96 |
if (iDecimalSeparator != ',')
|
|
97 |
{
|
|
98 |
iDecimalSeparator = '.';
|
|
99 |
}
|
|
100 |
|
|
101 |
iEdwinUtils = CMIDEdwinUtils::NewL(this, iDecimalSeparator);
|
|
102 |
|
|
103 |
// if text is invalid according to constraints, throw IllegalArgumentException,
|
|
104 |
// except for a PHONENUMBER which only has the invalid characters removed
|
|
105 |
if ((iConstraints & MMIDTextField::EConstraintMask) != MMIDTextField::EPhoneNumber
|
|
106 |
&& !iEdwinUtils->ConstraintsValidForText(aText,iConstraints,ETrue))
|
|
107 |
{
|
|
108 |
User::Leave(KErrArgument);
|
|
109 |
}
|
|
110 |
|
|
111 |
iMaxSize = aMaxSize;
|
|
112 |
if (iDisplayable)
|
|
113 |
{
|
|
114 |
iUIManager = iDisplayable->GetUIManager();
|
|
115 |
SetContainerWindowL(*iDisplayable);
|
|
116 |
SetAknEditorFlags(EAknEditorFlagEnableScrollBars | AknEdwinFlags());
|
|
117 |
}
|
|
118 |
else
|
|
119 |
{
|
|
120 |
iUIManager = iTextFieldItem->GetUIManager();
|
|
121 |
// TextField does not have any displayable yet available (before Form.Append())
|
|
122 |
// and EikEdwin needs to have a proper container window set, otherwise it may crash in singleLineEditor mode
|
|
123 |
CCoeControl::SetContainerWindowL(*(iUIManager->OpenMenuHandlerL()->GetDisplayable()));
|
|
124 |
}
|
|
125 |
|
|
126 |
TBool singleLineEditor = (iConstraints & MMIDTextField::EPassword);
|
|
127 |
|
|
128 |
AknEditUtils::ConstructEditingL(this, // aEdwin
|
|
129 |
aMaxSize, // aEditingSpace
|
|
130 |
(singleLineEditor ? 1 : 0), // aEditingWindow
|
|
131 |
EAknEditorCharactersLowerCase, // aCharacterCase
|
|
132 |
EAknEditorAlignLeft, // aJustification
|
|
133 |
ETrue, // aAllowedToMoveInsertionPoint
|
|
134 |
ETrue, // aCursorYesNo
|
|
135 |
EFalse); // aOverflowYesNo
|
|
136 |
|
|
137 |
if (iConstraints & MMIDTextField::EPassword)
|
|
138 |
{
|
|
139 |
iEdwinUserFlags |= CEikEdwin::EUserSuppliedText;
|
|
140 |
CreatePasswordTextL();
|
|
141 |
}
|
|
142 |
|
|
143 |
HBufC* buf = aText.AllocLC();
|
|
144 |
CMIDUtils::MapJavaToETextChars(buf);
|
|
145 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber)
|
|
146 |
{
|
|
147 |
iEdwinUtils->RemoveNonPhoneNumberChars(buf);
|
|
148 |
}
|
|
149 |
CEikEdwin::SetTextL(buf);
|
|
150 |
CreateTextViewL();
|
|
151 |
ProcessModifiers();
|
|
152 |
CleanupStack::PopAndDestroy(buf);
|
|
153 |
SetFEPModeAndCharFormat();
|
|
154 |
AddEdwinObserverL(this); // see HandleEdwinEventL
|
|
155 |
CreateNonMidletCommandsL();
|
|
156 |
|
|
157 |
|
|
158 |
iUIManager->OpenNaviPaneControllerL()->AddTickerObserverL(this);
|
|
159 |
|
|
160 |
// set the cursor position
|
|
161 |
CEikEdwin::SetCursorPosL(TextLength(), EFalse);
|
|
162 |
|
|
163 |
// Publish MIDP constraints via input capabilities of the CEikEdwin
|
|
164 |
// The information is needed by chinese VKB/HWR system that adjusts its behavior
|
|
165 |
// based on MIDP constraints (most notably by checking if the field is a PASSWORD field).
|
|
166 |
TCoeInputCapabilities inputCapabilities = InputCapabilities();
|
|
167 |
if (inputCapabilities != TCoeInputCapabilities::ENone)
|
|
168 |
{
|
|
169 |
MObjectProvider* mop = inputCapabilities.ObjectProvider();
|
|
170 |
if (mop)
|
|
171 |
{
|
|
172 |
CAknExtendedInputCapabilities* extendedInputCapabilities = NULL;
|
|
173 |
extendedInputCapabilities = mop->MopGetObject(extendedInputCapabilities);
|
|
174 |
if (extendedInputCapabilities)
|
|
175 |
{
|
|
176 |
extendedInputCapabilities->SetMIDPConstraints(iConstraints);
|
|
177 |
}
|
|
178 |
}
|
|
179 |
}
|
|
180 |
|
|
181 |
iThisMultitapKey = 0; // reset key counter
|
|
182 |
iLastMultitapKey = 0;
|
|
183 |
}
|
|
184 |
|
|
185 |
CMIDEdwin::CMIDEdwin(
|
|
186 |
TUint aConstraints, MMIDDisplayable* aDisplayable, CMIDTextFieldItem* aTextFieldItem)
|
|
187 |
: iDisplayable(static_cast<CMIDDisplayable*>(aDisplayable)),
|
|
188 |
iTextFieldItem(aTextFieldItem),
|
|
189 |
iConstraints(aConstraints),
|
|
190 |
iStateChanged(EFalse),
|
|
191 |
iKeyEventsPending(EFalse),
|
|
192 |
iInitialCurrentCase(0),
|
|
193 |
iInitialCurrentInputMode(0),
|
|
194 |
iInitialCurrentLanguage(ELangTest)
|
|
195 |
{
|
|
196 |
}
|
|
197 |
|
|
198 |
CMIDEdwin::~CMIDEdwin()
|
|
199 |
{
|
|
200 |
//phonebook fetch
|
|
201 |
delete iAiwPbkClient;
|
|
202 |
//edwin utils
|
|
203 |
delete iEdwinUtils;
|
|
204 |
if (iUIManager && iUIManager->GetNaviPaneController())
|
|
205 |
{
|
|
206 |
iUIManager->GetNaviPaneController()->RemoveTickerObserver(this);
|
|
207 |
}
|
|
208 |
RemoveNonMidletCommands();
|
|
209 |
}
|
|
210 |
|
|
211 |
void CMIDEdwin::DeleteTextL(TInt aOffset,TInt aLength)
|
|
212 |
{
|
|
213 |
// get all initial values before deletion
|
|
214 |
TInt oldSize = Size();
|
|
215 |
HBufC* oldText = GetTextInHBufL();
|
|
216 |
CleanupStack::PushL(oldText);
|
|
217 |
// get cursor position before deletion
|
|
218 |
TInt cursorPos = CEikEdwin::CursorPos();
|
|
219 |
|
|
220 |
if (IsReadyToDraw())
|
|
221 |
ClearSelectionL();
|
|
222 |
|
|
223 |
TInt withoutFEPSize = Size();
|
|
224 |
// if size is different then FEP transaction was canceled and some letters
|
|
225 |
// are missing - must work with original text
|
|
226 |
if (withoutFEPSize != oldSize)
|
|
227 |
{
|
|
228 |
CEikEdwin::SetTextL(oldText);
|
|
229 |
}
|
|
230 |
|
|
231 |
//
|
|
232 |
// Do the deletion, then roll back if it leaves invalid text
|
|
233 |
//
|
|
234 |
iText->DeleteL(aOffset,aLength);
|
|
235 |
//
|
|
236 |
TBool valid = iEdwinUtils->ConstraintsValidForText(Read(), iConstraints, ETrue);
|
|
237 |
if (!valid)
|
|
238 |
{
|
|
239 |
CEikEdwin::SetTextL(oldText);
|
|
240 |
}
|
|
241 |
CleanupStack::PopAndDestroy(oldText);
|
|
242 |
|
|
243 |
HandleTextChangedL();
|
|
244 |
if (IsReadyToDraw())
|
|
245 |
SetSelectionL(aOffset,aOffset);
|
|
246 |
|
|
247 |
if (!valid)
|
|
248 |
{
|
|
249 |
User::Leave(KErrArgument);
|
|
250 |
}
|
|
251 |
|
|
252 |
// Handle cursor moving
|
|
253 |
// Cursor is in the middle of delete area
|
|
254 |
if ((cursorPos > aOffset) && (cursorPos < (aOffset + aLength)))
|
|
255 |
{
|
|
256 |
CEikEdwin::SetCursorPosL(aOffset, EFalse);
|
|
257 |
}
|
|
258 |
// cursor is on the right side of delete area
|
|
259 |
else if (cursorPos > (aOffset + aLength))
|
|
260 |
{
|
|
261 |
TInt newPosition = cursorPos - aLength;
|
|
262 |
if (newPosition < 0)
|
|
263 |
{
|
|
264 |
newPosition = 0;
|
|
265 |
}
|
|
266 |
CEikEdwin::SetCursorPosL(newPosition, EFalse);
|
|
267 |
}
|
|
268 |
// cursor is on the left side of delete area
|
|
269 |
else
|
|
270 |
{
|
|
271 |
CEikEdwin::SetCursorPosL(cursorPos, EFalse);
|
|
272 |
}
|
|
273 |
}
|
|
274 |
|
|
275 |
void CMIDEdwin::SetTextL(const TDesC& aText)
|
|
276 |
{
|
|
277 |
// if text is invalid according to constraints, throw IllegalArgumentException,
|
|
278 |
// except for a PHONENUMBER which only has the invalid characters removed
|
|
279 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber)
|
|
280 |
{
|
|
281 |
}
|
|
282 |
else if (!iEdwinUtils->ConstraintsValidForText(aText, iConstraints, ETrue))
|
|
283 |
{
|
|
284 |
User::Leave(KErrArgument);
|
|
285 |
}
|
|
286 |
|
|
287 |
HBufC* buf = iEdwinUtils->ConvertToLocalizedLC(aText, iConstraints);
|
|
288 |
|
|
289 |
if (IsNumberConversionNeeded())
|
|
290 |
{
|
|
291 |
TPtr ptr = buf->Des();
|
|
292 |
AknTextUtils::LanguageSpecificNumberConversion(ptr);
|
|
293 |
}
|
|
294 |
|
|
295 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber)
|
|
296 |
{
|
|
297 |
iEdwinUtils->RemoveNonPhoneNumberChars(buf);
|
|
298 |
}
|
|
299 |
CEikEdwin::SetTextL(buf);
|
|
300 |
HandleTextChangedL();
|
|
301 |
CleanupStack::PopAndDestroy(buf);
|
|
302 |
|
|
303 |
// move cursor to end of the new text
|
|
304 |
CEikEdwin::SetCursorPosL(TextLength(), EFalse);
|
|
305 |
}
|
|
306 |
|
|
307 |
/** The first part of this method validates existing text + new text.
|
|
308 |
Then it carries on with text insertion. */
|
|
309 |
void CMIDEdwin::InsertTextL(const TDesC& aText, TInt aPosition)
|
|
310 |
{
|
|
311 |
//VALIDATE EXISTING TEXT
|
|
312 |
HBufC* temp = NULL;
|
|
313 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EDecimal)
|
|
314 |
{
|
|
315 |
// Convert decimal content to unlocalized form before testing validity
|
|
316 |
// of insertion.
|
|
317 |
temp = GetTextInHBufL();
|
|
318 |
if (temp)
|
|
319 |
{
|
|
320 |
CleanupStack::PushL(temp);
|
|
321 |
iEdwinUtils->ConvertFromLocalizedDecimal(temp);
|
|
322 |
}
|
|
323 |
}
|
|
324 |
|
|
325 |
if (aPosition < 0)
|
|
326 |
aPosition = 0;
|
|
327 |
|
|
328 |
TInt size = TextLength();
|
|
329 |
if (aPosition > size)
|
|
330 |
aPosition = size;
|
|
331 |
|
|
332 |
// if text is invalid according to constraints, throw IllegalArgumentException,
|
|
333 |
// except for a PHONENUMBER which only has the invalid characters removed
|
|
334 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber)
|
|
335 |
{
|
|
336 |
}
|
|
337 |
else if (!iEdwinUtils->ConstraintsValidForInsertedTextL((temp ? temp->Des() : Read()), aText, aPosition, iConstraints, ETrue))
|
|
338 |
{
|
|
339 |
User::Leave(KErrArgument);
|
|
340 |
}
|
|
341 |
if (temp)
|
|
342 |
{
|
|
343 |
CleanupStack::PopAndDestroy(temp);
|
|
344 |
temp = NULL;
|
|
345 |
}
|
|
346 |
//
|
|
347 |
//TEXT INSERTION STARTS HERE
|
|
348 |
if (IsReadyToDraw())
|
|
349 |
{
|
|
350 |
ClearSelectionL();
|
|
351 |
}
|
|
352 |
|
|
353 |
temp = iEdwinUtils->ConvertToLocalizedLC(aText, iConstraints);
|
|
354 |
|
|
355 |
|
|
356 |
if (IsNumberConversionNeeded())
|
|
357 |
{
|
|
358 |
TPtr ptr = temp->Des();
|
|
359 |
AknTextUtils::LanguageSpecificNumberConversion(ptr);
|
|
360 |
}
|
|
361 |
|
|
362 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber)
|
|
363 |
{
|
|
364 |
iEdwinUtils->RemoveNonPhoneNumberChars(temp);
|
|
365 |
}
|
|
366 |
iText->InsertL(aPosition, temp->Des());
|
|
367 |
|
|
368 |
HandleTextChangedL();
|
|
369 |
|
|
370 |
// Get the cursor position and move it forward along with inserter characters, if
|
|
371 |
// characters were inserted on the left side of the cursor.
|
|
372 |
TInt cursorPos = CEikEdwin::CursorPos();
|
|
373 |
TInt numberOfAddedCharacters = TextLength() - size;
|
|
374 |
|
|
375 |
if (cursorPos >= aPosition)
|
|
376 |
{
|
|
377 |
if ((cursorPos + numberOfAddedCharacters) < iMaxSize)
|
|
378 |
{
|
|
379 |
CEikEdwin::SetCursorPosL(cursorPos + numberOfAddedCharacters, EFalse);
|
|
380 |
}
|
|
381 |
}
|
|
382 |
|
|
383 |
UpdateTextCapacityIndicatorValueL();
|
|
384 |
|
|
385 |
CleanupStack::PopAndDestroy(temp);
|
|
386 |
}
|
|
387 |
|
|
388 |
/** Not used in current implementation; functionality
|
|
389 |
provided in CMIDEdwinControl and CMIDTextFieldItem
|
|
390 |
*/
|
|
391 |
void CMIDEdwin::SetConstraintsL(TUint /*aConstraints*/)
|
|
392 |
{
|
|
393 |
}
|
|
394 |
|
|
395 |
void CMIDEdwin::SetTextWithNewConstraintsL(HBufC* aText)
|
|
396 |
{
|
|
397 |
// If the current contents of the TextBox do not match the new constraints,the
|
|
398 |
// contents are set to empty, except for a PHONENUMBER which only has the
|
|
399 |
// invalid characters removed. Otherwise, set the text as given.
|
|
400 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber)
|
|
401 |
{
|
|
402 |
iEdwinUtils->RemoveNonPhoneNumberChars(aText);
|
|
403 |
CEikEdwin::SetTextL(aText);
|
|
404 |
}
|
|
405 |
else if (!iEdwinUtils->ConstraintsValidForText(aText->Des(), iConstraints & MMIDTextField::EConstraintMask, ETrue))
|
|
406 |
{
|
|
407 |
CEikEdwin::SetTextL(&KNullDesC);
|
|
408 |
}
|
|
409 |
else
|
|
410 |
{
|
|
411 |
CEikEdwin::SetTextL(aText);
|
|
412 |
}
|
|
413 |
HandleTextChangedL();
|
|
414 |
}
|
|
415 |
|
|
416 |
|
|
417 |
TInt CMIDEdwin::SetMaxSizeL(TInt aMaxSize)
|
|
418 |
{
|
|
419 |
TInt size = TextLength();
|
|
420 |
if (aMaxSize < size)
|
|
421 |
{
|
|
422 |
DeleteTextL(aMaxSize,size-aMaxSize);
|
|
423 |
}
|
|
424 |
iMaxSize = aMaxSize;
|
|
425 |
SetTextLimit(iMaxSize);
|
|
426 |
return iMaxSize;
|
|
427 |
}
|
|
428 |
|
|
429 |
TInt CMIDEdwin::GetMaxSize()
|
|
430 |
{
|
|
431 |
return iMaxSize;
|
|
432 |
}
|
|
433 |
|
|
434 |
|
|
435 |
TInt CMIDEdwin::Size()
|
|
436 |
{
|
|
437 |
TRAP_IGNORE(ResetNumericContentL());
|
|
438 |
return TextLength();
|
|
439 |
}
|
|
440 |
|
|
441 |
TInt CMIDEdwin::GetCaretPosition()
|
|
442 |
{
|
|
443 |
TRAP_IGNORE(ResetNumericContentL());
|
|
444 |
return CursorPos();
|
|
445 |
}
|
|
446 |
|
|
447 |
/** For a NUMERIC TextBox, clear the contents if the "displayed contents" are
|
|
448 |
in a state that is not valid "actual contents" for the current constraints.
|
|
449 |
*/
|
|
450 |
void CMIDEdwin::ResetNumericContentL()
|
|
451 |
{
|
|
452 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::ENumeric)
|
|
453 |
{
|
|
454 |
HBufC* buf = GetTextInHBufL();
|
|
455 |
if (buf != NULL)
|
|
456 |
{
|
|
457 |
CleanupStack::PushL(buf);
|
|
458 |
if (!iEdwinUtils->ConstraintsValidForText(buf->Des(), iConstraints, ETrue))
|
|
459 |
{
|
|
460 |
(buf->Des()).SetLength(0);
|
|
461 |
CEikEdwin::SetTextL(buf);
|
|
462 |
}
|
|
463 |
CleanupStack::PopAndDestroy(buf);
|
|
464 |
}
|
|
465 |
}
|
|
466 |
}
|
|
467 |
|
|
468 |
HBufC* CMIDEdwin::GetTextL()
|
|
469 |
{
|
|
470 |
HBufC* buf = GetTextInHBufL();
|
|
471 |
if (!buf)
|
|
472 |
{
|
|
473 |
buf = HBufC::NewL(0);
|
|
474 |
}
|
|
475 |
// convert decimal from localized to MIDlet-visible representation
|
|
476 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EDecimal)
|
|
477 |
{
|
|
478 |
iEdwinUtils->ConvertFromLocalizedDecimal(buf);
|
|
479 |
}
|
|
480 |
|
|
481 |
if (IsNumberConversionNeeded())
|
|
482 |
{
|
|
483 |
TPtr ptr = buf->Des();
|
|
484 |
AknTextUtils::ConvertDigitsTo(ptr, EDigitTypeWestern);
|
|
485 |
}
|
|
486 |
|
|
487 |
if (!iEdwinUtils->ConstraintsValidForText(buf->Des(), iConstraints, ETrue))
|
|
488 |
{
|
|
489 |
// The "displayed contents" of the TextBox may be in a state that is
|
|
490 |
// not valid "actual contents" for the current constraints; in that
|
|
491 |
// case, return an empty string and clear the TextBox contents.
|
|
492 |
(buf->Des()).SetLength(0);
|
|
493 |
CEikEdwin::SetTextL(buf);
|
|
494 |
}
|
|
495 |
else
|
|
496 |
{
|
|
497 |
// Otherwise, return a copy of the contents where newlines etc. are
|
|
498 |
// mapped to their Java representations.
|
|
499 |
CMIDUtils::MapETextToJavaChars(buf);
|
|
500 |
}
|
|
501 |
return buf;
|
|
502 |
}
|
|
503 |
|
|
504 |
|
|
505 |
void CMIDEdwin::CreatePasswordTextL()
|
|
506 |
{
|
|
507 |
CGlobalText* oldGText = STATIC_CAST(CGlobalText*,iText);
|
|
508 |
CPasswordBoxGlobalText* text=new(ELeave) CPasswordBoxGlobalText
|
|
509 |
(oldGText->GlobalParaFormatLayer(),oldGText->GlobalCharFormatLayer(),*this);
|
|
510 |
CleanupStack::PushL(text);
|
|
511 |
text->ConstructL();
|
|
512 |
CleanupStack::Pop(text);
|
|
513 |
|
|
514 |
delete iText;
|
|
515 |
iText = NULL;
|
|
516 |
|
|
517 |
SetDocumentContentL(*text,CEikEdwin::EUseText);
|
|
518 |
}
|
|
519 |
|
|
520 |
/**
|
|
521 |
* Need to recreate TextView here such that it uses the right window
|
|
522 |
*/
|
|
523 |
void CMIDEdwin::SetContainerWindowL(const CCoeControl& aContainer)
|
|
524 |
{
|
|
525 |
SetObserver(this); //Prevent MCoeControlObserver::EEventStateChanged going to Form
|
|
526 |
|
|
527 |
CEikEdwin::SetContainerWindowL(aContainer);
|
|
528 |
}
|
|
529 |
|
|
530 |
TKeyResponse CMIDEdwin::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
|
|
531 |
{
|
|
532 |
// store the key pressed last time, used for warning beeps while reaching size limit
|
|
533 |
if (aType == EEventKeyDown)
|
|
534 |
{
|
|
535 |
iLastMultitapKey = iThisMultitapKey;
|
|
536 |
iThisMultitapKey = aKeyEvent.iScanCode;
|
|
537 |
}
|
|
538 |
|
|
539 |
if (aType == EEventKeyDown)
|
|
540 |
{
|
|
541 |
iKeyEventsPending = ETrue;
|
|
542 |
}
|
|
543 |
else if (aType == EEventKeyUp)
|
|
544 |
{
|
|
545 |
iKeyEventsPending = EFalse;
|
|
546 |
}
|
|
547 |
//
|
|
548 |
// Post ItemStateChangedEvent before a command is delivered to the Form's CommandListener
|
|
549 |
//
|
|
550 |
TUint scanCode = aKeyEvent.iScanCode;
|
|
551 |
TBool losingFocus = EFalse;
|
|
552 |
|
|
553 |
CMIDMenuHandler* menuHandler = iUIManager->GetMenuHandler();
|
|
554 |
// Enter Key
|
|
555 |
//
|
|
556 |
//TextFieldItem
|
|
557 |
if (iTextFieldItem)
|
|
558 |
{
|
|
559 |
// QWERTY and VKB Enter Key
|
|
560 |
if (scanCode == EStdKeyEnter && aType == EEventKeyDown && !useEnterKey)
|
|
561 |
{
|
|
562 |
useEnterKey=true;
|
|
563 |
}
|
|
564 |
if ((scanCode == EStdKeyEnter && aType == EEventKeyUp && useEnterKey) ||
|
|
565 |
(aType == EEventKey && aKeyEvent.iCode == EKeyEnter))
|
|
566 |
//TextFieldItem with NUMERIC,DECIMAL and PHONENUMBER constraint
|
|
567 |
if (IsConstraintSet(MMIDTextField::ENumeric) ||
|
|
568 |
IsConstraintSet(MMIDTextField::EDecimal) ||
|
|
569 |
IsConstraintSet(MMIDTextField::ENumeric + MMIDTextField::EPassword))
|
|
570 |
{
|
|
571 |
useEnterKey=false;
|
|
572 |
//Activate default command
|
|
573 |
if (iTextFieldItem->DefaultCommand())
|
|
574 |
{
|
|
575 |
menuHandler->ProcessCommandL(
|
|
576 |
iTextFieldItem->CommandList()->CommandOffset() +
|
|
577 |
iTextFieldItem->CommandList()->FindCommandIndex(iTextFieldItem->DefaultCommand()));
|
|
578 |
}
|
|
579 |
// Show ctx menu or activate command
|
|
580 |
else
|
|
581 |
{
|
|
582 |
menuHandler->ShowMenuL(CMIDMenuHandler::EOkMenu);
|
|
583 |
if (menuHandler->MenuItemsCount() <= 1)
|
|
584 |
menuHandler->ProcessCommandL(iTextFieldItem->CommandList()->CommandOffset());
|
|
585 |
}
|
|
586 |
|
|
587 |
return EKeyWasConsumed;
|
|
588 |
|
|
589 |
}
|
|
590 |
else
|
|
591 |
{
|
|
592 |
//TextFieldItem with PHONENUMBER constraint
|
|
593 |
if (IsConstraintSet(MMIDTextField::EPhoneNumber) ||
|
|
594 |
IsConstraintSet(MMIDTextField::EPhoneNumber + MMIDTextField::EPassword))
|
|
595 |
{
|
|
596 |
useEnterKey = false;
|
|
597 |
//Activate default command
|
|
598 |
if (iTextFieldItem->DefaultCommand())
|
|
599 |
{
|
|
600 |
menuHandler->ProcessCommandL(
|
|
601 |
iTextFieldItem->CommandList()->CommandOffset() +
|
|
602 |
iTextFieldItem->CommandList()->FindCommandIndex(iTextFieldItem->DefaultCommand()));
|
|
603 |
}
|
|
604 |
// Show options menu or activate command
|
|
605 |
else
|
|
606 |
{
|
|
607 |
menuHandler->ShowMenuL(CMIDMenuHandler::EOkMenu);
|
|
608 |
if (menuHandler->MenuItemsCount() == 1)
|
|
609 |
{
|
|
610 |
menuHandler->ProcessCommandL(iTextFieldItem->CommandList()->CommandOffset());
|
|
611 |
}
|
|
612 |
}
|
|
613 |
return EKeyWasConsumed;
|
|
614 |
}
|
|
615 |
else
|
|
616 |
{
|
|
617 |
//TextFieldItem with ANY,PASSWORD constraint
|
|
618 |
if (iConstraints == MMIDTextField::EPassword)
|
|
619 |
{
|
|
620 |
useEnterKey=false;
|
|
621 |
//Activate default command
|
|
622 |
if (iTextFieldItem->DefaultCommand())
|
|
623 |
{
|
|
624 |
menuHandler->ProcessCommandL(
|
|
625 |
iTextFieldItem->CommandList()->CommandOffset() +
|
|
626 |
iTextFieldItem->CommandList()->FindCommandIndex(iTextFieldItem->DefaultCommand()));
|
|
627 |
}
|
|
628 |
// Show options menu or activate command
|
|
629 |
else
|
|
630 |
{
|
|
631 |
menuHandler->ShowMenuL(CMIDMenuHandler::EOkMenu);
|
|
632 |
if (menuHandler->MenuItemsCount() == 1)
|
|
633 |
{
|
|
634 |
menuHandler->ProcessCommandL(
|
|
635 |
iTextFieldItem->CommandList()->CommandOffset());
|
|
636 |
}
|
|
637 |
}
|
|
638 |
return EKeyWasConsumed;
|
|
639 |
|
|
640 |
}
|
|
641 |
|
|
642 |
}
|
|
643 |
}
|
|
644 |
if (aKeyEvent.iCode == EKeyEnter && aType == EEventKey)
|
|
645 |
{
|
|
646 |
//TextFieldItem with EMAILADDR constraint
|
|
647 |
if (IsConstraintSet(MMIDTextField::EMailAddr) ||
|
|
648 |
IsConstraintSet(MMIDTextField::EUrl))
|
|
649 |
{
|
|
650 |
//Show menu or activate command
|
|
651 |
if (!iTextFieldItem->DefaultCommand())
|
|
652 |
{
|
|
653 |
menuHandler->ShowMenuL(CMIDMenuHandler::EOkMenu);
|
|
654 |
if (menuHandler->MenuItemsCount() <= 1)
|
|
655 |
{
|
|
656 |
menuHandler->ProcessCommandL(
|
|
657 |
iTextFieldItem->CommandList()->CommandOffset());
|
|
658 |
}
|
|
659 |
return EKeyWasConsumed;
|
|
660 |
}
|
|
661 |
|
|
662 |
}
|
|
663 |
}
|
|
664 |
}
|
|
665 |
// End Enter Key
|
|
666 |
//
|
|
667 |
|
|
668 |
//
|
|
669 |
// keyboard menu
|
|
670 |
//
|
|
671 |
switch (scanCode)
|
|
672 |
{
|
|
673 |
case EStdKeyF1:
|
|
674 |
case EStdKeyMenu:
|
|
675 |
losingFocus=ETrue;
|
|
676 |
}
|
|
677 |
//
|
|
678 |
// Pause the ticker for five sec if # key received
|
|
679 |
if (aKeyEvent.iScanCode == EStdKeyHash && !IsReadOnly()) //0x7f
|
|
680 |
{
|
|
681 |
iUIManager->OpenNaviPaneControllerL()->PauseTickerL(TICKER_PAUSE_INTERVAL, this);
|
|
682 |
}
|
|
683 |
//
|
|
684 |
// Non keyboard zoom,menu,etc.
|
|
685 |
//
|
|
686 |
if (scanCode>=ESpecialKeyBase && scanCode<(ESpecialKeyBase+ESpecialKeyCount))
|
|
687 |
losingFocus=ETrue;
|
|
688 |
//
|
|
689 |
// CBA buttons:
|
|
690 |
//
|
|
691 |
if (scanCode>=EStdKeyDevice0 && scanCode<=EStdKeyDeviceF)
|
|
692 |
losingFocus=ETrue;
|
|
693 |
//
|
|
694 |
if (iTextFieldItem && losingFocus && iStateChanged)
|
|
695 |
{
|
|
696 |
iTextFieldItem->HandleControlEventL(this,MCoeControlObserver::EEventStateChanged);
|
|
697 |
iStateChanged=EFalse;
|
|
698 |
}
|
|
699 |
|
|
700 |
// ignore up and down arrows on PASSWORD TextField to avoid funny behaviour
|
|
701 |
// with line breaks
|
|
702 |
if (iDisplayable && (iConstraints & MMIDTextField::EPassword)
|
|
703 |
&& (aKeyEvent.iCode == EKeyDownArrow || aKeyEvent.iCode == EKeyUpArrow))
|
|
704 |
{
|
|
705 |
return EKeyWasConsumed;
|
|
706 |
}
|
|
707 |
|
|
708 |
// when pressing the send key on a phonenumber-type box, call the number
|
|
709 |
#ifdef RD_SCALABLE_UI_V2
|
|
710 |
if ((aType == EEventKey) && (scanCode == EStdKeyYes))
|
|
711 |
#else
|
|
712 |
if ((aType == EEventKeyUp) && (scanCode == EStdKeyYes))
|
|
713 |
#endif // RD_SCALABLE_UI_V2
|
|
714 |
{
|
|
715 |
if ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber)
|
|
716 |
{
|
|
717 |
CreatePhoneCallL();
|
|
718 |
return EKeyWasConsumed;
|
|
719 |
}
|
|
720 |
}
|
|
721 |
|
|
722 |
#ifdef RD_SCALABLE_UI_V2
|
|
723 |
if ((aType == EEventKey) && (iConstraints & MMIDTextField::EPassword)
|
|
724 |
#else
|
|
725 |
if ((aType == EEventKeyDown) && (iConstraints & MMIDTextField::EPassword)
|
|
726 |
#endif // RD_SCALABLE_UI_V2
|
|
727 |
&& iTextFieldItem) // type == TextField
|
|
728 |
{
|
|
729 |
static_cast<CPasswordBoxGlobalText*>(iText)->RejectNextKey(scanCode == EStdKeyEnter);
|
|
730 |
}
|
|
731 |
|
|
732 |
#ifdef RD_SCALABLE_UI_V2
|
|
733 |
if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKey || aType == EEventKeyUp) && !IsReadOnly() &&
|
|
734 |
#else
|
|
735 |
if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKeyUp) && !IsReadOnly() &&
|
|
736 |
#endif // RD_SCALABLE_UI_V2
|
|
737 |
((scanCode==EStdKeyNkpAsterisk) || (scanCode == EStdKeyMinus) || (scanCode==EStdKeyNkpMinus) || (scanCode == 0x2A) || (scanCode == 0x2D) ||
|
|
738 |
(TChar(aKeyEvent.iCode) == TChar('-') && scanCode != EStdKeyMinus)))
|
|
739 |
{
|
|
740 |
HandleMinusCharEventL(EEventTextUpdate);
|
|
741 |
CEikEdwin::ReportEdwinEventL(EEventTextUpdate);
|
|
742 |
UpdateTextCapacityIndicatorValueL();
|
|
743 |
return EKeyWasConsumed;
|
|
744 |
}
|
|
745 |
|
|
746 |
//handling of qwerty keypad "-" or "." pressing in Decimal mode
|
|
747 |
#ifdef RD_SCALABLE_UI_V2
|
|
748 |
if (IsConstraintSet(MMIDTextField::EDecimal) && (aType == EEventKey) && !IsReadOnly() &&
|
|
749 |
#else
|
|
750 |
if (IsConstraintSet(MMIDTextField::EDecimal) && (aType == EEventKeyUp) && !IsReadOnly() &&
|
|
751 |
#endif // RD_SCALABLE_UI_V2
|
|
752 |
((scanCode==EStdKeyMinus) || (scanCode==EStdKeyFullStop)))
|
|
753 |
{
|
|
754 |
CPlainText* res = CEikEdwin::Text();
|
|
755 |
TInt textLength = CEikEdwin::TextLength();
|
|
756 |
if (scanCode == EStdKeyMinus && textLength < iMaxSize)
|
|
757 |
{
|
|
758 |
res->InsertL(CEikEdwin::CursorPos(), KMinusChar);
|
|
759 |
}
|
|
760 |
else if (scanCode == EStdKeyFullStop && textLength < iMaxSize)
|
|
761 |
{
|
|
762 |
res->InsertL(CEikEdwin::CursorPos(), KFullStopChar);
|
|
763 |
}
|
|
764 |
|
|
765 |
HandleTextChangedL(); // notify editor about the text changes
|
|
766 |
CEikEdwin::ReportEdwinEventL(EEventTextUpdate);
|
|
767 |
TInt cursorPos = CEikEdwin::CursorPos();
|
|
768 |
|
|
769 |
if (CEikEdwin::TextLength() < iMaxSize)
|
|
770 |
{
|
|
771 |
CEikEdwin::SetCursorPosL(cursorPos + 1, EFalse);
|
|
772 |
}
|
|
773 |
else if (cursorPos == (iMaxSize - 1) && cursorPos == textLength &&
|
|
774 |
(scanCode == EStdKeyFullStop || scanCode == EStdKeyMinus))
|
|
775 |
{
|
|
776 |
CEikEdwin::SetCursorPosL(iMaxSize, EFalse);
|
|
777 |
}
|
|
778 |
}
|
|
779 |
//Error tone playing case1:
|
|
780 |
//Play error tone if TextBox/TextField is read-only or maximum length has been reached.
|
|
781 |
//Here is handling of keys 0...9 for full keyboard and itu-t, but NOT virtual keyboard.
|
|
782 |
if (aType == EEventKeyDown
|
|
783 |
&& ((scanCode >= KKeyQwerty0 && scanCode <= KKeyQwerty9)
|
|
784 |
|| scanCode == EStdKeyHash
|
|
785 |
|| scanCode == EStdKeyNkpAsterisk
|
|
786 |
|| scanCode == KMidpKeyNkpAsteriskHW))
|
|
787 |
{
|
|
788 |
if ((scanCode == EStdKeyNkpAsterisk || scanCode == KMidpKeyNkpAsteriskHW)
|
|
789 |
&& !IsReadOnly() && IsConstraintSet(MMIDTextField::ENumeric))
|
|
790 |
{
|
|
791 |
//Do nothing here in case of minus char toggle
|
|
792 |
}
|
|
793 |
else if (IsReadOnly())
|
|
794 |
{
|
|
795 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone);
|
|
796 |
UpdateTextCapacityIndicatorValueL();
|
|
797 |
return EKeyWasConsumed;
|
|
798 |
}
|
|
799 |
|
|
800 |
// All possible sources of warning beep are separated to be easy to read
|
|
801 |
else if (TextLength() >= iMaxSize)
|
|
802 |
{
|
|
803 |
TInt ret = KErrNone;
|
|
804 |
TInt inputModeValue = AknEditorCurrentInputMode();
|
|
805 |
if (inputModeValue != EAknEditorTextInputMode)
|
|
806 |
{
|
|
807 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone);
|
|
808 |
UpdateTextCapacityIndicatorValueL();
|
|
809 |
return EKeyWasConsumed;
|
|
810 |
}
|
|
811 |
|
|
812 |
TInt aknRepositoryValue = 0;
|
|
813 |
CRepository* aknFepRepository = NULL;
|
|
814 |
TRAP(ret, aknFepRepository = CRepository::NewL(KCRUidAknFep));
|
|
815 |
if ((ret != KErrNone) || (!aknFepRepository))
|
|
816 |
{
|
|
817 |
// if we cannot get the repository (something is wrong), play nothing
|
|
818 |
UpdateTextCapacityIndicatorValueL();
|
|
819 |
return EKeyWasConsumed;
|
|
820 |
}
|
|
821 |
aknFepRepository->Get(KAknFepPredTxtFlag, aknRepositoryValue);
|
|
822 |
|
|
823 |
delete aknFepRepository;
|
|
824 |
aknFepRepository = NULL;
|
|
825 |
|
|
826 |
if (aknRepositoryValue == 1) // 1 means the predictive input is on
|
|
827 |
{
|
|
828 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone);
|
|
829 |
UpdateTextCapacityIndicatorValueL();
|
|
830 |
return EKeyWasConsumed;
|
|
831 |
}
|
|
832 |
// now only nonpredictive textinput is left
|
|
833 |
if (iThisMultitapKey != iLastMultitapKey) // different key tapped -> no multitap
|
|
834 |
{
|
|
835 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone);
|
|
836 |
UpdateTextCapacityIndicatorValueL();
|
|
837 |
iThisMultitapKey = 0;
|
|
838 |
iLastMultitapKey = 0;
|
|
839 |
return EKeyWasConsumed;
|
|
840 |
}
|
|
841 |
}
|
|
842 |
}
|
|
843 |
|
|
844 |
if (aType != EEventKey && aKeyEvent.iScanCode != EStdKeyApplication0)
|
|
845 |
{
|
|
846 |
UpdateTextCapacityIndicatorValueL();
|
|
847 |
return EKeyWasConsumed;
|
|
848 |
}
|
|
849 |
|
|
850 |
|
|
851 |
TKeyResponse response = EKeyWasNotConsumed;
|
|
852 |
|
|
853 |
// Error tone playing case2:
|
|
854 |
// Play error tone if TextBox/TextField is read-only or maximum length has been reached.
|
|
855 |
// Here is handling of full keyboard keys(NOT 0...9) and all virtual keyboard keys
|
|
856 |
// (camera and menu key not included).
|
|
857 |
// (Note: Virtual keyboard sends only EEventKey type events, not up or down events)
|
|
858 |
// (Note: Error tone is played when there is no text to be replaced i.e. no text has been painted)
|
|
859 |
if (!iEdwinUtils->IsNavigationKey(aKeyEvent) && !iEdwinUtils->IsHotKeyL(aKeyEvent, iCoeEnv) && aKeyEvent.iCode != EKeyYes &&
|
|
860 |
(!iKeyEventsPending || (scanCode < KKeyQwerty0 || scanCode > KKeyQwerty9)) &&
|
|
861 |
(aKeyEvent.iCode != EKeyApplication0 && scanCode != EStdKeyApplication0 &&
|
|
862 |
aKeyEvent.iCode != EKeyApplication19 && scanCode != EStdKeyApplication19))
|
|
863 |
{
|
|
864 |
if (IsReadOnly() || (TextLength() >= iMaxSize && aKeyEvent.iCode != EKeyBackspace))
|
|
865 |
{
|
|
866 |
//SelectionLength() > 0 if text has been selected/painted
|
|
867 |
if (SelectionLength() == 0)
|
|
868 |
{
|
|
869 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone);
|
|
870 |
}
|
|
871 |
response = CEikEdwin::OfferKeyEventL(aKeyEvent,aType);
|
|
872 |
UpdateTextCapacityIndicatorValueL();
|
|
873 |
return response;
|
|
874 |
}
|
|
875 |
}
|
|
876 |
|
|
877 |
TBool valid = EFalse;
|
|
878 |
//
|
|
879 |
if (iEdwinUtils->IsNavigationKey(aKeyEvent) || iEdwinUtils->IsHotKeyL(aKeyEvent, iCoeEnv))
|
|
880 |
{
|
|
881 |
HBufC* oldText = GetTextInHBufL();
|
|
882 |
CleanupStack::PushL(oldText);
|
|
883 |
TCursorSelection sel = Selection();
|
|
884 |
//
|
|
885 |
response = CEikEdwin::OfferKeyEventL(aKeyEvent,aType);
|
|
886 |
valid = iEdwinUtils->ConstraintsValidForText(iText?Read():TPtrC(),iConstraints,EFalse);
|
|
887 |
//
|
|
888 |
if (!valid)
|
|
889 |
{
|
|
890 |
CEikEdwin::SetTextL(oldText);
|
|
891 |
HandleTextChangedL();
|
|
892 |
SetSelectionL(sel.iCursorPos,sel.iAnchorPos);
|
|
893 |
response = EKeyWasConsumed;
|
|
894 |
}
|
|
895 |
//
|
|
896 |
CleanupStack::PopAndDestroy(oldText);
|
|
897 |
UpdateTextCapacityIndicatorValueL();
|
|
898 |
return response;
|
|
899 |
}
|
|
900 |
else
|
|
901 |
{
|
|
902 |
TBuf<1> key;
|
|
903 |
key.Append(TChar(aKeyEvent.iCode));
|
|
904 |
valid = iEdwinUtils->ConstraintsValidForInsertedTextL(iText?Read():TPtrC(), key, CursorPos(), iConstraints, EFalse);
|
|
905 |
if (valid)
|
|
906 |
{
|
|
907 |
if (iTextFieldItem && (aKeyEvent.iCode == EKeyEnter) &&
|
|
908 |
(((iConstraints & MMIDTextField::EConstraintMask) != MMIDTextField::EAny) ||
|
|
909 |
(iConstraints & MMIDTextField::EPassword)))
|
|
910 |
{//enter key for NON ANY or ANY | PASSWORD editors
|
|
911 |
return EKeyWasNotConsumed; //must do command triggering in this case
|
|
912 |
}
|
|
913 |
|
|
914 |
response = CEikEdwin::OfferKeyEventL(aKeyEvent,aType);
|
|
915 |
UpdateTextCapacityIndicatorValueL();
|
|
916 |
}
|
|
917 |
else
|
|
918 |
{
|
|
919 |
// If minus char was entered in full querty editor mode
|
|
920 |
if (IsConstraintSet(MMIDTextField::EDecimal) &&
|
|
921 |
(aType == EEventKey) && !IsReadOnly() &&
|
|
922 |
(TChar(aKeyEvent.iCode) == TChar('-') && scanCode != EStdKeyMinus))
|
|
923 |
{
|
|
924 |
CPlainText* res = CEikEdwin::Text();
|
|
925 |
|
|
926 |
if (res && TChar(aKeyEvent.iCode) == TChar('-') &&
|
|
927 |
TextLength() < iMaxSize)
|
|
928 |
{
|
|
929 |
TInt textLength = TextLength();
|
|
930 |
res->InsertL(GetCaretPosition(), KMinusChar);
|
|
931 |
HandleTextChangedL(); // notify editor about the text changes
|
|
932 |
CEikEdwin::ReportEdwinEventL(EEventTextUpdate);
|
|
933 |
TInt cursorPos = GetCaretPosition();
|
|
934 |
|
|
935 |
if (TextLength() < iMaxSize)
|
|
936 |
{
|
|
937 |
CEikEdwin::SetCursorPosL(GetCaretPosition() + 1, EFalse);
|
|
938 |
}
|
|
939 |
else if (cursorPos == (iMaxSize - 1) && cursorPos == textLength)
|
|
940 |
|
|
941 |
{
|
|
942 |
CEikEdwin::SetCursorPosL(iMaxSize, EFalse);
|
|
943 |
}
|
|
944 |
}
|
|
945 |
}
|
|
946 |
|
|
947 |
}
|
|
948 |
return response;
|
|
949 |
}
|
|
950 |
}
|
|
951 |
|
|
952 |
void CMIDEdwin::FocusChanged(TDrawNow aDrawNow)
|
|
953 |
{
|
|
954 |
CEikEdwin::FocusChanged(aDrawNow);
|
|
955 |
TBool isFocused = IsFocused();
|
|
956 |
TInt ret = KErrNone;
|
|
957 |
|
|
958 |
// in case of TextFieldItem iDisplayable is not valid do not use it.
|
|
959 |
if (!iDisplayable && iTextFieldItem->Form() == NULL)
|
|
960 |
{
|
|
961 |
return;
|
|
962 |
}
|
|
963 |
|
|
964 |
if (!IsReadOnly())
|
|
965 |
{
|
|
966 |
if (isFocused)
|
|
967 |
{
|
|
968 |
TRAP(
|
|
969 |
ret,
|
|
970 |
iUIManager->OpenNaviPaneControllerL()->PauseTickerL(TICKER_PAUSE_INTERVAL, this));
|
|
971 |
}
|
|
972 |
else
|
|
973 |
{
|
|
974 |
TRAP(
|
|
975 |
ret,
|
|
976 |
iUIManager->OpenNaviPaneControllerL()->PauseTickerL(0, this));
|
|
977 |
}
|
|
978 |
}
|
|
979 |
//
|
|
980 |
// Post ItemStateChangedEvent if focus moves away
|
|
981 |
//
|
|
982 |
if (iTextFieldItem && !isFocused && (iStateChanged))
|
|
983 |
{
|
|
984 |
TRAP(ret,iTextFieldItem->HandleControlEventL(this,MCoeControlObserver::EEventStateChanged));
|
|
985 |
iStateChanged=EFalse;
|
|
986 |
}
|
|
987 |
|
|
988 |
// Show text input indicator is the last thing we want to do
|
|
989 |
TRAP(ret,UpdateTextCapacityIndicatorValueL());
|
|
990 |
}
|
|
991 |
|
|
992 |
void CMIDEdwin::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType)
|
|
993 |
{
|
|
994 |
switch (aEventType)
|
|
995 |
{
|
|
996 |
case MCoeControlObserver::EEventStateChanged:
|
|
997 |
iStateChanged=ETrue;
|
|
998 |
break;
|
|
999 |
default:
|
|
1000 |
break;
|
|
1001 |
}
|
|
1002 |
}
|
|
1003 |
|
|
1004 |
void CMIDEdwin::ProcessModifiers()
|
|
1005 |
{
|
|
1006 |
// set general edwin attributes according to TextBox constraints
|
|
1007 |
SetReadOnly(iConstraints & MMIDTextField::EUneditable);
|
|
1008 |
}
|
|
1009 |
|
|
1010 |
void CMIDEdwin::HandleMinusCharEventL(TEdwinEvent aEventType)
|
|
1011 |
{
|
|
1012 |
|
|
1013 |
if ((aEventType == EEventTextUpdate) && ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::ENumeric))
|
|
1014 |
{
|
|
1015 |
ClearSelectionL();
|
|
1016 |
CPlainText* res = CEikEdwin::Text();
|
|
1017 |
TBuf<1> firstChar;
|
|
1018 |
if (CEikEdwin::TextLength() != 0)
|
|
1019 |
{
|
|
1020 |
res->Extract(firstChar, 0, 1);
|
|
1021 |
}
|
|
1022 |
TInt cursorPos = CEikEdwin::CursorPos();
|
|
1023 |
//toggle '-' char in the first position
|
|
1024 |
TInt pos = firstChar.Locate(TChar('-'));
|
|
1025 |
if (pos == KErrNotFound)
|
|
1026 |
{
|
|
1027 |
if (CEikEdwin::TextLength() < iMaxSize)
|
|
1028 |
{
|
|
1029 |
res->InsertL(0, KMinusChar);
|
|
1030 |
cursorPos++;
|
|
1031 |
}
|
|
1032 |
else
|
|
1033 |
{
|
|
1034 |
//play error sound if text limit is to be exceeded
|
|
1035 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone);
|
|
1036 |
}
|
|
1037 |
}
|
|
1038 |
else
|
|
1039 |
{
|
|
1040 |
TBool deletion = res->DeleteL(0,1);
|
|
1041 |
if (cursorPos >= 1)
|
|
1042 |
{
|
|
1043 |
cursorPos--;
|
|
1044 |
}
|
|
1045 |
}
|
|
1046 |
HandleTextChangedL(); // notify editor about the text changes
|
|
1047 |
CEikEdwin::SetCursorPosL(cursorPos, EFalse);
|
|
1048 |
}
|
|
1049 |
}
|
|
1050 |
|
|
1051 |
void CMIDEdwin::HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType)
|
|
1052 |
{
|
|
1053 |
if (iTextFieldItem && aEventType == MEikEdwinObserver::EEventTextUpdate)
|
|
1054 |
{
|
|
1055 |
// notify Java that text has changed with itemStateChanged()
|
|
1056 |
iTextFieldItem->HandleControlEventL(aEdwin, MCoeControlObserver::EEventStateChanged);
|
|
1057 |
}
|
|
1058 |
|
|
1059 |
if (aEventType == MEikEdwinObserver::EEventTextUpdate)
|
|
1060 |
{
|
|
1061 |
// handles clearing multitap counter
|
|
1062 |
if ((iLastMultitapKey != 0) && (iLastMultitapKey != iThisMultitapKey))
|
|
1063 |
{
|
|
1064 |
iLastMultitapKey = 0;
|
|
1065 |
}
|
|
1066 |
else
|
|
1067 |
{
|
|
1068 |
iThisMultitapKey = 0;
|
|
1069 |
iLastMultitapKey = 0;
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
TBool textChanged = EFalse;
|
|
1073 |
|
|
1074 |
// in DECIMAL mode, don't allow changes that would result
|
|
1075 |
// in an illegal string;
|
|
1076 |
// 1) if there is a minus, it must be the first character
|
|
1077 |
// 2) there can be at most one decimal separator
|
|
1078 |
if ((iConstraints &
|
|
1079 |
MMIDTextField::EConstraintMask) == MMIDTextField::EDecimal)
|
|
1080 |
{
|
|
1081 |
HBufC* res = NULL;
|
|
1082 |
TRAPD(err, { res = GetTextInHBufL();});
|
|
1083 |
if (err != KErrNone || !res)
|
|
1084 |
{
|
|
1085 |
return;
|
|
1086 |
}
|
|
1087 |
CleanupStack::PushL(res);
|
|
1088 |
|
|
1089 |
TInt illegalCharPos = -1;
|
|
1090 |
TPtr16 ptr = res->Des();
|
|
1091 |
TInt minusPos = ptr.LocateReverse(TChar('-'));
|
|
1092 |
TInt endCursorPos = CEikEdwin::CursorPos();
|
|
1093 |
|
|
1094 |
// check if minus sign is inserted on incorrect place
|
|
1095 |
// (not at the beginning)
|
|
1096 |
if ((minusPos != KErrNotFound) && (minusPos != 0))
|
|
1097 |
{
|
|
1098 |
// check if minus sign isn't inserted twice
|
|
1099 |
if (minusPos != ptr.Locate(TChar('-')))
|
|
1100 |
{
|
|
1101 |
illegalCharPos = minusPos;
|
|
1102 |
}
|
|
1103 |
// insert minus char at the beginning of decimal field
|
|
1104 |
else
|
|
1105 |
{
|
|
1106 |
ptr.Delete(minusPos, 1);
|
|
1107 |
ptr.Insert(0, KMinusChar);
|
|
1108 |
minusPos = 0;
|
|
1109 |
CEikEdwin::SetTextL(res);
|
|
1110 |
textChanged = ETrue;
|
|
1111 |
}
|
|
1112 |
}
|
|
1113 |
|
|
1114 |
TInt pointPosL = ptr.Locate(iDecimalSeparator);
|
|
1115 |
TInt pointPosR = ptr.LocateReverse(iDecimalSeparator);
|
|
1116 |
TInt cursorPos = CEikEdwin::CursorPos();
|
|
1117 |
if ((minusPos != KErrNotFound) && (pointPosL == 0))
|
|
1118 |
{
|
|
1119 |
illegalCharPos = pointPosL;
|
|
1120 |
}
|
|
1121 |
else if (pointPosL != pointPosR)
|
|
1122 |
{
|
|
1123 |
illegalCharPos = pointPosR;
|
|
1124 |
}
|
|
1125 |
|
|
1126 |
// if minus or dot/comma char is displayed more than once
|
|
1127 |
if (illegalCharPos >= 0)
|
|
1128 |
{
|
|
1129 |
// deleting second minus or dot/comma char
|
|
1130 |
// and set cursor position on the right place
|
|
1131 |
ptr.Delete(illegalCharPos, 1);
|
|
1132 |
CEikEdwin::SetTextL(res);
|
|
1133 |
textChanged = ETrue;
|
|
1134 |
if (cursorPos >= 1)
|
|
1135 |
{
|
|
1136 |
if (cursorPos == illegalCharPos)
|
|
1137 |
{
|
|
1138 |
cursorPos--;
|
|
1139 |
}
|
|
1140 |
endCursorPos = cursorPos;
|
|
1141 |
}
|
|
1142 |
}
|
|
1143 |
CEikEdwin::SetCursorPosL(endCursorPos, EFalse);
|
|
1144 |
CleanupStack::Pop(res);
|
|
1145 |
delete res;
|
|
1146 |
}
|
|
1147 |
else if (((iConstraints &
|
|
1148 |
MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr)||
|
|
1149 |
((iConstraints &
|
|
1150 |
MMIDTextField::EConstraintMask) == MMIDTextField::EUrl))
|
|
1151 |
{
|
|
1152 |
HBufC* res = NULL;
|
|
1153 |
TRAPD(err, { res = GetTextL();});
|
|
1154 |
if (err != KErrNone || !res)
|
|
1155 |
{
|
|
1156 |
return;
|
|
1157 |
}
|
|
1158 |
CleanupStack::PushL(res);
|
|
1159 |
|
|
1160 |
// In EMAIL and URL mode, don't allow changes that would result
|
|
1161 |
// in an illegal string; if there is '/n' or '/f', and line breaks
|
|
1162 |
// are not supported, chars need to be changed to space
|
|
1163 |
// SetText function before actual text change checks if line
|
|
1164 |
// breaks are not supported
|
|
1165 |
TPtr16 text = res->Des();
|
|
1166 |
TInt tmpPos;
|
|
1167 |
|
|
1168 |
if ((text.Locate(TChar('\n'))) >=0 ||
|
|
1169 |
(text.Locate(TChar('\f'))) >=0)
|
|
1170 |
{
|
|
1171 |
tmpPos = CEikEdwin::CursorPos();
|
|
1172 |
SetTextL(*res);
|
|
1173 |
CEikEdwin::SetCursorPosL(tmpPos, EFalse);
|
|
1174 |
}
|
|
1175 |
|
|
1176 |
textChanged = ETrue;
|
|
1177 |
CleanupStack::Pop(res);
|
|
1178 |
delete res;
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
// if there were any modifications the text is updated
|
|
1182 |
if (textChanged)
|
|
1183 |
{
|
|
1184 |
HandleTextChangedL();
|
|
1185 |
}
|
|
1186 |
}
|
|
1187 |
|
|
1188 |
|
|
1189 |
}
|
|
1190 |
|
|
1191 |
void CMIDEdwin::SetInitialInputModeL(const TDesC& aCharacterSubset)
|
|
1192 |
{
|
|
1193 |
iEdwinUtils->SetInitialInputModeL(aCharacterSubset,
|
|
1194 |
iConstraints,
|
|
1195 |
iInitialCurrentCase,
|
|
1196 |
iInitialCurrentInputMode,
|
|
1197 |
iInitialCurrentLanguage);
|
|
1198 |
|
|
1199 |
TUint constraint = iConstraints & MMIDTextField::EConstraintMask;
|
|
1200 |
|
|
1201 |
// Set permitted case modes for TextBox in lowercase or uppercase mode.
|
|
1202 |
if (aCharacterSubset.Compare(KMidpUppercaseLatin) == 0 ||
|
|
1203 |
aCharacterSubset.Compare(KMidpLowercaseLatin) == 0)
|
|
1204 |
{
|
|
1205 |
//Setting permited case mode for TextField in ANY do panic
|
|
1206 |
//when TextField loses focus.
|
|
1207 |
if (iTextFieldItem && iConstraints == MMIDTextField::EAny)
|
|
1208 |
{
|
|
1209 |
return;
|
|
1210 |
}
|
|
1211 |
// MIDP_UPPERCASE_LATIN or MIDP_LOWERCASE_LATIN are ignored if
|
|
1212 |
// INITIAL_CAPS_SENTENCE or INITIAL_CAPS_WORD modifier in ANY.
|
|
1213 |
if (!(iConstraints & MMIDTextField::EInitialCapsWordSentence ||
|
|
1214 |
iConstraints & MMIDTextField::EInitialCapsWord) ||
|
|
1215 |
constraint != MMIDTextField::EAny)
|
|
1216 |
{
|
|
1217 |
// If initial input mode is uppercase or lowercase then permit
|
|
1218 |
// only explicit case mode changes, automatic changes are not
|
|
1219 |
// allowed.
|
|
1220 |
SetAknEditorPermittedCaseModes(EAknEditorUpperCase |
|
|
1221 |
EAknEditorLowerCase);
|
|
1222 |
}
|
|
1223 |
}
|
|
1224 |
else
|
|
1225 |
{
|
|
1226 |
SetAknEditorPermittedCaseModes(EAknEditorAllCaseModes);
|
|
1227 |
}
|
|
1228 |
|
|
1229 |
}
|
|
1230 |
|
|
1231 |
|
|
1232 |
TBool CMIDEdwin::IsNumberConversionNeeded()
|
|
1233 |
{
|
|
1234 |
return iEdwinUtils->IsNumberConversionNeeded(GetConstraints());
|
|
1235 |
}
|
|
1236 |
|
|
1237 |
void CMIDEdwin::SetFEPModeAndCharFormat()
|
|
1238 |
{
|
|
1239 |
iEdwinUtils->SetFEPModeAndCharFormat(iConstraints, this);
|
|
1240 |
}
|
|
1241 |
|
|
1242 |
/** Create non-midlet commands according to the constraints and add them
|
|
1243 |
to either the displayable or to the item. Commands will be processed in ProcessCommandL(). */
|
|
1244 |
void CMIDEdwin::CreateNonMidletCommandsL()
|
|
1245 |
{
|
|
1246 |
if (((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber) && !(iConstraints & MMIDTextField::EUneditable))
|
|
1247 |
{
|
|
1248 |
AddCommandToEdwinL(R_MIDP_PB_FETCH_NUMBER_SHORT_COMMAND_TEXT, R_MIDP_PB_FETCH_NUMBER_COMMAND_TEXT, CMIDEdwinUtils::EMenuCommandFetchPhoneNumber);
|
|
1249 |
AddCommandToEdwinL(R_MIDP_CREATE_CALL_SHORT_COMMAND_TEXT, R_MIDP_CREATE_CALL_COMMAND_TEXT, CMIDEdwinUtils::EMenuCommandCreatePhoneCall);
|
|
1250 |
}
|
|
1251 |
|
|
1252 |
if (((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber) && (iConstraints & MMIDTextField::EUneditable))
|
|
1253 |
{
|
|
1254 |
AddCommandToEdwinL(R_MIDP_CREATE_CALL_SHORT_COMMAND_TEXT, R_MIDP_CREATE_CALL_COMMAND_TEXT, CMIDEdwinUtils::EMenuCommandCreatePhoneCall);
|
|
1255 |
}
|
|
1256 |
|
|
1257 |
if (((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr) && !(iConstraints & MMIDTextField::EUneditable))
|
|
1258 |
{
|
|
1259 |
AddCommandToEdwinL(R_MIDP_PB_FETCH_EMAIL_SHORT_COMMAND_TEXT, R_MIDP_PB_FETCH_EMAIL_COMMAND_TEXT, CMIDEdwinUtils::EMenuCommandFetchEmailAddress);
|
|
1260 |
}
|
|
1261 |
}
|
|
1262 |
|
|
1263 |
/**
|
|
1264 |
Creates and adds new command to edwin based on shot & long label resource ids
|
|
1265 |
and other parameters.
|
|
1266 |
*/
|
|
1267 |
void CMIDEdwin::AddCommandToEdwinL(TInt aCommandResIdShort,
|
|
1268 |
TInt aCommandResIdLong,
|
|
1269 |
TInt aCommandId)
|
|
1270 |
{
|
|
1271 |
TBuf<64> shortLabel;
|
|
1272 |
iEikonEnv->ReadResourceL(shortLabel, aCommandResIdShort);
|
|
1273 |
TBuf<64> longLabel;
|
|
1274 |
iEikonEnv->ReadResourceL(longLabel, aCommandResIdLong);
|
|
1275 |
|
|
1276 |
|
|
1277 |
MMIDCommand* cmd = CMIDCommand::NewL(shortLabel, longLabel, MMIDCommand::EItem, 0, aCommandId);
|
|
1278 |
CleanupStack::PushL(cmd);
|
|
1279 |
|
|
1280 |
STATIC_CAST(CMIDCommand*,cmd)->SetObserver(this);
|
|
1281 |
|
|
1282 |
AddCommandToEdwinL(*cmd);
|
|
1283 |
CleanupStack::Pop(cmd);
|
|
1284 |
}
|
|
1285 |
|
|
1286 |
/**
|
|
1287 |
Creates and adds new command to edwin, short label is the same as long label.
|
|
1288 |
*/
|
|
1289 |
void CMIDEdwin::AddCommandToEdwinL(TInt aCommandResId, TInt aCommandId)
|
|
1290 |
{
|
|
1291 |
AddCommandToEdwinL(aCommandResId, aCommandResId, aCommandId);
|
|
1292 |
}
|
|
1293 |
|
|
1294 |
/** This method is called from the destructor and removes
|
|
1295 |
the commands added by CreateNonMidletCommandsL(). To do
|
|
1296 |
this we examine cmds on the list (either of the displayable
|
|
1297 |
or the item as applicable) and remove those whose observer is us.
|
|
1298 |
*/
|
|
1299 |
void CMIDEdwin::RemoveNonMidletCommands()
|
|
1300 |
{
|
|
1301 |
CMIDCommandList* list = NULL;
|
|
1302 |
if (iDisplayable)
|
|
1303 |
{
|
|
1304 |
list = STATIC_CAST(CMIDDisplayable*, iDisplayable)->MainCommandList();
|
|
1305 |
}
|
|
1306 |
else if (iTextFieldItem)
|
|
1307 |
{
|
|
1308 |
list = STATIC_CAST(CMIDTextFieldItem*, iTextFieldItem)->CommandList();
|
|
1309 |
}
|
|
1310 |
|
|
1311 |
if (!list)
|
|
1312 |
{
|
|
1313 |
return;
|
|
1314 |
}
|
|
1315 |
|
|
1316 |
for (TInt i = 0; i < list->Count(); i++)
|
|
1317 |
{
|
|
1318 |
CMIDCommand* cmd = list->At(i).iCommand;
|
|
1319 |
if (cmd && (cmd->Observer() == this))
|
|
1320 |
{
|
|
1321 |
list->Remove(cmd);
|
|
1322 |
cmd->Dispose();
|
|
1323 |
i--;
|
|
1324 |
}
|
|
1325 |
}
|
|
1326 |
}
|
|
1327 |
|
|
1328 |
/** Process non-midlet commands according to their unique negative id. See
|
|
1329 |
MMIDCommandObserver, FetchFromPhoneBoolL() and CreateNonMidletCommandsL(). */
|
|
1330 |
TBool CMIDEdwin::ProcessCommandL(CMIDCommand* aCommand)
|
|
1331 |
{
|
|
1332 |
ASSERT(aCommand);
|
|
1333 |
TBool ret = EFalse;
|
|
1334 |
|
|
1335 |
switch (aCommand->Id())
|
|
1336 |
{
|
|
1337 |
case CMIDEdwinUtils::EMenuCommandFetchPhoneNumber:
|
|
1338 |
// for fetching data from phonebook
|
|
1339 |
if (!iAiwPbkClient)
|
|
1340 |
{
|
|
1341 |
iAiwPbkClient = CMIDAiwPbk2Client::NewL(*this);
|
|
1342 |
}
|
|
1343 |
iAiwPbkClient->FetchFromPhoneBookL(EAiwPhoneNumberSelect);
|
|
1344 |
ret = ETrue;
|
|
1345 |
break;
|
|
1346 |
case CMIDEdwinUtils::EMenuCommandFetchEmailAddress:
|
|
1347 |
// for fetching data from phonebook
|
|
1348 |
if (!iAiwPbkClient)
|
|
1349 |
{
|
|
1350 |
iAiwPbkClient = CMIDAiwPbk2Client::NewL(*this);
|
|
1351 |
}
|
|
1352 |
iAiwPbkClient->FetchFromPhoneBookL(EAiwEMailSelect);
|
|
1353 |
ret = ETrue;
|
|
1354 |
break;
|
|
1355 |
case CMIDEdwinUtils::EMenuCommandCreatePhoneCall:
|
|
1356 |
CreatePhoneCallL();
|
|
1357 |
ret = ETrue;
|
|
1358 |
break;
|
|
1359 |
default:
|
|
1360 |
break;
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
return ret;
|
|
1364 |
}
|
|
1365 |
|
|
1366 |
void CMIDEdwin::CreatePhoneCallL()
|
|
1367 |
{
|
|
1368 |
iEdwinUtils->CreatePhoneCallL(TextLength(), CCoeEnv::Static()->WsSession(), this);
|
|
1369 |
}
|
|
1370 |
|
|
1371 |
/** From MTickerObserver: If the ticker is showing disable the displaying of
|
|
1372 |
edit indicators in the navi pane. **/
|
|
1373 |
void CMIDEdwin::TickerShowing(TBool aShowing)
|
|
1374 |
{
|
|
1375 |
TInt flags = aShowing ? EAknEditorFlagNoEditIndicators | AknEdwinFlags() :
|
|
1376 |
~EAknEditorFlagNoEditIndicators & AknEdwinFlags();
|
|
1377 |
|
|
1378 |
SetAknEditorFlags(flags);
|
|
1379 |
}
|
|
1380 |
|
|
1381 |
void CMIDEdwin::HandleCurrentL(TBool aActivate)
|
|
1382 |
{
|
|
1383 |
// when becoming the current Displayable, set editor input mode
|
|
1384 |
// to the one set by SetInitialInputModeL
|
|
1385 |
if (aActivate &&
|
|
1386 |
((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EAny ||
|
|
1387 |
(iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr ||
|
|
1388 |
(iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EUrl))
|
|
1389 |
{
|
|
1390 |
if (iInitialCurrentLanguage)
|
|
1391 |
{
|
|
1392 |
SetAknEditorLocalLanguage(iInitialCurrentLanguage);
|
|
1393 |
if (iInitialCurrentInputMode == 0)
|
|
1394 |
{
|
|
1395 |
// clears any number mode used previously
|
|
1396 |
SetAknEditorCurrentInputMode(EAknEditorNullInputMode);
|
|
1397 |
}
|
|
1398 |
}
|
|
1399 |
|
|
1400 |
if (iInitialCurrentInputMode)
|
|
1401 |
{
|
|
1402 |
SetAknEditorCurrentInputMode(iInitialCurrentInputMode);
|
|
1403 |
}
|
|
1404 |
|
|
1405 |
if (iInitialCurrentCase)
|
|
1406 |
{
|
|
1407 |
TInt initialCurrentCase = iInitialCurrentCase;
|
|
1408 |
if ((iConstraints & MMIDTextField::EPassword ||
|
|
1409 |
iConstraints & MMIDTextField::EMailAddr ||
|
|
1410 |
iConstraints & MMIDTextField::EUrl) &&
|
|
1411 |
iInitialCurrentCase == EAknEditorTextCase)
|
|
1412 |
{
|
|
1413 |
// Text case is not used in passwords, emailaddrs and urls
|
|
1414 |
initialCurrentCase = EAknEditorLowerCase;
|
|
1415 |
}
|
|
1416 |
SetAknEditorCurrentCase(initialCurrentCase);
|
|
1417 |
SetAknEditorCase(initialCurrentCase);
|
|
1418 |
}
|
|
1419 |
}
|
|
1420 |
if (aActivate)
|
|
1421 |
{
|
|
1422 |
UpdateTextCapacityIndicatorValueL();
|
|
1423 |
}
|
|
1424 |
}
|
|
1425 |
|
|
1426 |
/** Update the text capacity indicator if we have focus and are not read only.*/
|
|
1427 |
void CMIDEdwin::UpdateTextCapacityIndicatorValueL()
|
|
1428 |
{
|
|
1429 |
TBool isActive = iDisplayable ? iDisplayable->IsActive() :
|
|
1430 |
(iTextFieldItem->Form() ? iTextFieldItem->Form()->CurrentDisplayable().IsActive() : EFalse);
|
|
1431 |
|
|
1432 |
if (IsFocused() && isActive && !(iConstraints & MMIDTextField::EUneditable))
|
|
1433 |
{
|
|
1434 |
// Navi pane controller is opened on constructor phase so it should exists
|
|
1435 |
iUIManager->OpenNaviPaneControllerL()->UpdateTextInputIndicatorL(
|
|
1436 |
iMaxSize - TextLength());
|
|
1437 |
iDisplayingCapacityIndic = ETrue;
|
|
1438 |
}
|
|
1439 |
else if (iDisplayingCapacityIndic)
|
|
1440 |
{
|
|
1441 |
// Navi pane controller is opened on constructor phase so it should exists
|
|
1442 |
iUIManager->OpenNaviPaneControllerL()->UpdateTextInputIndicatorL(-1);
|
|
1443 |
iDisplayingCapacityIndic = EFalse;
|
|
1444 |
}
|
|
1445 |
}
|
|
1446 |
|
|
1447 |
/** Updates capacity indicator when text is pasted. */
|
|
1448 |
void CMIDEdwin::HandleTextPastedL(TInt aStartPos,TInt& aLength)
|
|
1449 |
{
|
|
1450 |
// When TextBox field is NUMERIC, PHONENUMBER or DECIMAL new line
|
|
1451 |
// characters if exists in copied text must be filtered out before pasting
|
|
1452 |
|
|
1453 |
if ((IsConstraintSet(MMIDTextField::ENumeric) ||
|
|
1454 |
IsConstraintSet(MMIDTextField::EPhoneNumber) ||
|
|
1455 |
IsConstraintSet(MMIDTextField::EDecimal)) != EFalse)
|
|
1456 |
{
|
|
1457 |
HBufC* hbuf = GetTextInHBufL();
|
|
1458 |
TPtr strPtr = hbuf->Des();
|
|
1459 |
TInt firstPos = strPtr.Find(KLineSeparator);
|
|
1460 |
|
|
1461 |
if (firstPos != KErrNotFound)
|
|
1462 |
{
|
|
1463 |
CleanupStack::PushL(hbuf);
|
|
1464 |
while (firstPos != KErrNotFound)
|
|
1465 |
{
|
|
1466 |
strPtr.Delete(firstPos, KLineSeparator().Length());
|
|
1467 |
firstPos = strPtr.Find(KLineSeparator);
|
|
1468 |
}
|
|
1469 |
CEikEdwin::SetTextL(hbuf);
|
|
1470 |
CleanupStack::Pop(hbuf);
|
|
1471 |
}
|
|
1472 |
delete hbuf;
|
|
1473 |
}
|
|
1474 |
UpdateTextCapacityIndicatorValueL();
|
|
1475 |
CEikEdwin::HandleTextPastedL(aStartPos, aLength);
|
|
1476 |
}
|
|
1477 |
|
|
1478 |
TPtrC CMIDEdwin::Read() const
|
|
1479 |
{
|
|
1480 |
if (iConstraints & MMIDTextField::EPassword)
|
|
1481 |
{
|
|
1482 |
return static_cast<CPasswordBoxGlobalText*>(iText)->ClearText();
|
|
1483 |
}
|
|
1484 |
else
|
|
1485 |
{
|
|
1486 |
return iText->Read(0,TextLength());
|
|
1487 |
}
|
|
1488 |
}
|