author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:23:59 +0300 | |
branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 71 | d5e927d5853b |
permissions | -rw-r--r-- |
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 |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
23 |
#include <EIKCOCTL.rsg> |
66 | 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 |
} |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
773 |
else if (cursorPos == (iMaxSize - 1) && cursorPos == textLength && scanCode==EStdKeyFullStop) |
66 | 774 |
{ |
775 |
CEikEdwin::SetCursorPosL(iMaxSize, EFalse); |
|
776 |
} |
|
777 |
} |
|
778 |
//Error tone playing case1: |
|
779 |
//Play error tone if TextBox/TextField is read-only or maximum length has been reached. |
|
780 |
//Here is handling of keys 0...9 for full keyboard and itu-t, but NOT virtual keyboard. |
|
781 |
if (aType == EEventKeyDown |
|
782 |
&& ((scanCode >= KKeyQwerty0 && scanCode <= KKeyQwerty9) |
|
783 |
|| scanCode == EStdKeyHash |
|
784 |
|| scanCode == EStdKeyNkpAsterisk |
|
785 |
|| scanCode == KMidpKeyNkpAsteriskHW)) |
|
786 |
{ |
|
787 |
if ((scanCode == EStdKeyNkpAsterisk || scanCode == KMidpKeyNkpAsteriskHW) |
|
788 |
&& !IsReadOnly() && IsConstraintSet(MMIDTextField::ENumeric)) |
|
789 |
{ |
|
790 |
//Do nothing here in case of minus char toggle |
|
791 |
} |
|
792 |
else if (IsReadOnly()) |
|
793 |
{ |
|
794 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone); |
|
795 |
UpdateTextCapacityIndicatorValueL(); |
|
796 |
return EKeyWasConsumed; |
|
797 |
} |
|
798 |
||
799 |
// All possible sources of warning beep are separated to be easy to read |
|
800 |
else if (TextLength() >= iMaxSize) |
|
801 |
{ |
|
802 |
TInt ret = KErrNone; |
|
803 |
TInt inputModeValue = AknEditorCurrentInputMode(); |
|
804 |
if (inputModeValue != EAknEditorTextInputMode) |
|
805 |
{ |
|
806 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone); |
|
807 |
UpdateTextCapacityIndicatorValueL(); |
|
808 |
return EKeyWasConsumed; |
|
809 |
} |
|
810 |
||
811 |
TInt aknRepositoryValue = 0; |
|
812 |
CRepository* aknFepRepository = NULL; |
|
813 |
TRAP(ret, aknFepRepository = CRepository::NewL(KCRUidAknFep)); |
|
814 |
if ((ret != KErrNone) || (!aknFepRepository)) |
|
815 |
{ |
|
816 |
// if we cannot get the repository (something is wrong), play nothing |
|
817 |
UpdateTextCapacityIndicatorValueL(); |
|
818 |
return EKeyWasConsumed; |
|
819 |
} |
|
820 |
aknFepRepository->Get(KAknFepPredTxtFlag, aknRepositoryValue); |
|
821 |
||
822 |
delete aknFepRepository; |
|
823 |
aknFepRepository = NULL; |
|
824 |
||
825 |
if (aknRepositoryValue == 1) // 1 means the predictive input is on |
|
826 |
{ |
|
827 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone); |
|
828 |
UpdateTextCapacityIndicatorValueL(); |
|
829 |
return EKeyWasConsumed; |
|
830 |
} |
|
831 |
// now only nonpredictive textinput is left |
|
832 |
if (iThisMultitapKey != iLastMultitapKey) // different key tapped -> no multitap |
|
833 |
{ |
|
834 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone); |
|
835 |
UpdateTextCapacityIndicatorValueL(); |
|
836 |
iThisMultitapKey = 0; |
|
837 |
iLastMultitapKey = 0; |
|
838 |
return EKeyWasConsumed; |
|
839 |
} |
|
840 |
} |
|
841 |
} |
|
842 |
||
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
843 |
if (aType != EEventKey) |
66 | 844 |
{ |
845 |
UpdateTextCapacityIndicatorValueL(); |
|
846 |
return EKeyWasConsumed; |
|
847 |
} |
|
848 |
||
849 |
||
850 |
TKeyResponse response = EKeyWasNotConsumed; |
|
851 |
||
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
852 |
//Error tone playing case2: |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
853 |
//Play error tone if TextBox/TextField is read-only or maximum length has been reached. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
854 |
//Here is handling of full keyboard keys(NOT 0...9) and all virtual keyboard keys. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
855 |
//(Note: Virtual keyboard sends only EEventKey type events, not up or down events) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
856 |
//(Note: Error tone is played when there is no text to be replaced i.e. no text has been painted) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
857 |
if (!iEdwinUtils->IsNavigationKey(aKeyEvent) && !iEdwinUtils->IsHotKeyL(aKeyEvent, iCoeEnv) && !aKeyEvent.iCode == EKeyYes && |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
858 |
(!iKeyEventsPending || (scanCode < KKeyQwerty0 || scanCode > KKeyQwerty9))) |
66 | 859 |
{ |
860 |
if (IsReadOnly() || (TextLength() >= iMaxSize && aKeyEvent.iCode != EKeyBackspace)) |
|
861 |
{ |
|
862 |
//SelectionLength() > 0 if text has been selected/painted |
|
863 |
if (SelectionLength() == 0) |
|
864 |
{ |
|
865 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone); |
|
866 |
} |
|
867 |
response = CEikEdwin::OfferKeyEventL(aKeyEvent,aType); |
|
868 |
UpdateTextCapacityIndicatorValueL(); |
|
869 |
return response; |
|
870 |
} |
|
871 |
} |
|
872 |
||
873 |
TBool valid = EFalse; |
|
874 |
// |
|
875 |
if (iEdwinUtils->IsNavigationKey(aKeyEvent) || iEdwinUtils->IsHotKeyL(aKeyEvent, iCoeEnv)) |
|
876 |
{ |
|
877 |
HBufC* oldText = GetTextInHBufL(); |
|
878 |
CleanupStack::PushL(oldText); |
|
879 |
TCursorSelection sel = Selection(); |
|
880 |
// |
|
881 |
response = CEikEdwin::OfferKeyEventL(aKeyEvent,aType); |
|
882 |
valid = iEdwinUtils->ConstraintsValidForText(iText?Read():TPtrC(),iConstraints,EFalse); |
|
883 |
// |
|
884 |
if (!valid) |
|
885 |
{ |
|
886 |
CEikEdwin::SetTextL(oldText); |
|
887 |
HandleTextChangedL(); |
|
888 |
SetSelectionL(sel.iCursorPos,sel.iAnchorPos); |
|
889 |
response = EKeyWasConsumed; |
|
890 |
} |
|
891 |
// |
|
892 |
CleanupStack::PopAndDestroy(oldText); |
|
893 |
UpdateTextCapacityIndicatorValueL(); |
|
894 |
return response; |
|
895 |
} |
|
896 |
else |
|
897 |
{ |
|
898 |
TBuf<1> key; |
|
899 |
key.Append(TChar(aKeyEvent.iCode)); |
|
900 |
valid = iEdwinUtils->ConstraintsValidForInsertedTextL(iText?Read():TPtrC(), key, CursorPos(), iConstraints, EFalse); |
|
901 |
if (valid) |
|
902 |
{ |
|
903 |
if (iTextFieldItem && (aKeyEvent.iCode == EKeyEnter) && |
|
904 |
(((iConstraints & MMIDTextField::EConstraintMask) != MMIDTextField::EAny) || |
|
905 |
(iConstraints & MMIDTextField::EPassword))) |
|
906 |
{//enter key for NON ANY or ANY | PASSWORD editors |
|
907 |
return EKeyWasNotConsumed; //must do command triggering in this case |
|
908 |
} |
|
909 |
||
910 |
response = CEikEdwin::OfferKeyEventL(aKeyEvent,aType); |
|
911 |
UpdateTextCapacityIndicatorValueL(); |
|
912 |
} |
|
913 |
else |
|
914 |
{ |
|
915 |
// If minus char was entered in full querty editor mode |
|
916 |
if (IsConstraintSet(MMIDTextField::EDecimal) && |
|
917 |
(aType == EEventKey) && !IsReadOnly() && |
|
918 |
(TChar(aKeyEvent.iCode) == TChar('-') && scanCode != EStdKeyMinus)) |
|
919 |
{ |
|
920 |
CPlainText* res = CEikEdwin::Text(); |
|
921 |
||
922 |
if (res && TChar(aKeyEvent.iCode) == TChar('-') && |
|
923 |
TextLength() < iMaxSize) |
|
924 |
{ |
|
925 |
res->InsertL(GetCaretPosition(), KMinusChar); |
|
926 |
HandleTextChangedL(); // notify editor about the text changes |
|
927 |
CEikEdwin::ReportEdwinEventL(EEventTextUpdate); |
|
928 |
||
929 |
if (TextLength() < iMaxSize) |
|
930 |
{ |
|
931 |
CEikEdwin::SetCursorPosL(GetCaretPosition() + 1, EFalse); |
|
932 |
} |
|
933 |
} |
|
934 |
} |
|
935 |
||
936 |
} |
|
937 |
return response; |
|
938 |
} |
|
939 |
} |
|
940 |
||
941 |
void CMIDEdwin::FocusChanged(TDrawNow aDrawNow) |
|
942 |
{ |
|
943 |
CEikEdwin::FocusChanged(aDrawNow); |
|
944 |
TBool isFocused = IsFocused(); |
|
945 |
TInt ret = KErrNone; |
|
946 |
||
947 |
// in case of TextFieldItem iDisplayable is not valid do not use it. |
|
948 |
if (!iDisplayable && iTextFieldItem->Form() == NULL) |
|
949 |
{ |
|
950 |
return; |
|
951 |
} |
|
952 |
||
953 |
if (!IsReadOnly()) |
|
954 |
{ |
|
955 |
if (isFocused) |
|
956 |
{ |
|
957 |
TRAP( |
|
958 |
ret, |
|
959 |
iUIManager->OpenNaviPaneControllerL()->PauseTickerL(TICKER_PAUSE_INTERVAL, this)); |
|
960 |
} |
|
961 |
else |
|
962 |
{ |
|
963 |
TRAP( |
|
964 |
ret, |
|
965 |
iUIManager->OpenNaviPaneControllerL()->PauseTickerL(0, this)); |
|
966 |
} |
|
967 |
} |
|
968 |
// |
|
969 |
// Post ItemStateChangedEvent if focus moves away |
|
970 |
// |
|
971 |
if (iTextFieldItem && !isFocused && (iStateChanged)) |
|
972 |
{ |
|
973 |
TRAP(ret,iTextFieldItem->HandleControlEventL(this,MCoeControlObserver::EEventStateChanged)); |
|
974 |
iStateChanged=EFalse; |
|
975 |
} |
|
976 |
||
977 |
// Show text input indicator is the last thing we want to do |
|
978 |
TRAP(ret,UpdateTextCapacityIndicatorValueL()); |
|
979 |
} |
|
980 |
||
981 |
void CMIDEdwin::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType) |
|
982 |
{ |
|
983 |
switch (aEventType) |
|
984 |
{ |
|
985 |
case MCoeControlObserver::EEventStateChanged: |
|
986 |
iStateChanged=ETrue; |
|
987 |
break; |
|
988 |
default: |
|
989 |
break; |
|
990 |
} |
|
991 |
} |
|
992 |
||
993 |
void CMIDEdwin::ProcessModifiers() |
|
994 |
{ |
|
995 |
// set general edwin attributes according to TextBox constraints |
|
996 |
SetReadOnly(iConstraints & MMIDTextField::EUneditable); |
|
997 |
} |
|
998 |
||
999 |
void CMIDEdwin::HandleMinusCharEventL(TEdwinEvent aEventType) |
|
1000 |
{ |
|
1001 |
||
1002 |
if ((aEventType == EEventTextUpdate) && ((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::ENumeric)) |
|
1003 |
{ |
|
1004 |
ClearSelectionL(); |
|
1005 |
CPlainText* res = CEikEdwin::Text(); |
|
1006 |
TBuf<1> firstChar; |
|
1007 |
if (CEikEdwin::TextLength() != 0) |
|
1008 |
{ |
|
1009 |
res->Extract(firstChar, 0, 1); |
|
1010 |
} |
|
1011 |
TInt cursorPos = CEikEdwin::CursorPos(); |
|
1012 |
//toggle '-' char in the first position |
|
1013 |
TInt pos = firstChar.Locate(TChar('-')); |
|
1014 |
if (pos == KErrNotFound) |
|
1015 |
{ |
|
1016 |
if (CEikEdwin::TextLength() < iMaxSize) |
|
1017 |
{ |
|
1018 |
res->InsertL(0, KMinusChar); |
|
1019 |
cursorPos++; |
|
1020 |
} |
|
1021 |
else |
|
1022 |
{ |
|
1023 |
//play error sound if text limit is to be exceeded |
|
1024 |
iAvkonAppUi->KeySounds()->PlaySound(EAvkonSIDErrorTone); |
|
1025 |
} |
|
1026 |
} |
|
1027 |
else |
|
1028 |
{ |
|
1029 |
TBool deletion = res->DeleteL(0,1); |
|
1030 |
if (cursorPos >= 1) |
|
1031 |
{ |
|
1032 |
cursorPos--; |
|
1033 |
} |
|
1034 |
} |
|
1035 |
HandleTextChangedL(); // notify editor about the text changes |
|
1036 |
CEikEdwin::SetCursorPosL(cursorPos, EFalse); |
|
1037 |
} |
|
1038 |
} |
|
1039 |
||
1040 |
void CMIDEdwin::HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType) |
|
1041 |
{ |
|
1042 |
if (iTextFieldItem && aEventType == MEikEdwinObserver::EEventTextUpdate) |
|
1043 |
{ |
|
1044 |
// notify Java that text has changed with itemStateChanged() |
|
1045 |
iTextFieldItem->HandleControlEventL(aEdwin, MCoeControlObserver::EEventStateChanged); |
|
1046 |
} |
|
1047 |
||
1048 |
if (aEventType == MEikEdwinObserver::EEventTextUpdate) |
|
1049 |
{ |
|
1050 |
// handles clearing multitap counter |
|
1051 |
if ((iLastMultitapKey != 0) && (iLastMultitapKey != iThisMultitapKey)) |
|
1052 |
{ |
|
1053 |
iLastMultitapKey = 0; |
|
1054 |
} |
|
1055 |
else |
|
1056 |
{ |
|
1057 |
iThisMultitapKey = 0; |
|
1058 |
iLastMultitapKey = 0; |
|
1059 |
} |
|
1060 |
||
1061 |
TBool textChanged = EFalse; |
|
1062 |
||
1063 |
// in DECIMAL mode, don't allow changes that would result |
|
1064 |
// in an illegal string; |
|
1065 |
// 1) if there is a minus, it must be the first character |
|
1066 |
// 2) there can be at most one decimal separator |
|
1067 |
if ((iConstraints & |
|
1068 |
MMIDTextField::EConstraintMask) == MMIDTextField::EDecimal) |
|
1069 |
{ |
|
1070 |
HBufC* res = NULL; |
|
1071 |
TRAPD(err, { res = GetTextInHBufL();}); |
|
1072 |
if (err != KErrNone || !res) |
|
1073 |
{ |
|
1074 |
return; |
|
1075 |
} |
|
1076 |
CleanupStack::PushL(res); |
|
1077 |
||
1078 |
TInt illegalCharPos = -1; |
|
1079 |
TPtr16 ptr = res->Des(); |
|
1080 |
TInt minusPos = ptr.LocateReverse(TChar('-')); |
|
1081 |
TInt endCursorPos = CEikEdwin::CursorPos(); |
|
1082 |
||
1083 |
// check if minus sign is inserted on incorrect place |
|
1084 |
// (not at the beginning) |
|
1085 |
if ((minusPos != KErrNotFound) && (minusPos != 0)) |
|
1086 |
{ |
|
1087 |
// check if minus sign isn't inserted twice |
|
1088 |
if (minusPos != ptr.Locate(TChar('-'))) |
|
1089 |
{ |
|
1090 |
illegalCharPos = minusPos; |
|
1091 |
} |
|
1092 |
// insert minus char at the beginning of decimal field |
|
1093 |
else |
|
1094 |
{ |
|
1095 |
ptr.Delete(minusPos, 1); |
|
1096 |
ptr.Insert(0, KMinusChar); |
|
1097 |
minusPos = 0; |
|
1098 |
CEikEdwin::SetTextL(res); |
|
1099 |
textChanged = ETrue; |
|
1100 |
} |
|
1101 |
} |
|
1102 |
||
1103 |
TInt pointPosL = ptr.Locate(iDecimalSeparator); |
|
1104 |
TInt pointPosR = ptr.LocateReverse(iDecimalSeparator); |
|
1105 |
TInt cursorPos = CEikEdwin::CursorPos(); |
|
1106 |
if ((minusPos != KErrNotFound) && (pointPosL == 0)) |
|
1107 |
{ |
|
1108 |
illegalCharPos = pointPosL; |
|
1109 |
} |
|
1110 |
else if (pointPosL != pointPosR) |
|
1111 |
{ |
|
1112 |
illegalCharPos = pointPosR; |
|
1113 |
} |
|
1114 |
||
1115 |
// if minus or dot/comma char is displayed more than once |
|
1116 |
if (illegalCharPos >= 0) |
|
1117 |
{ |
|
1118 |
// deleting second minus or dot/comma char |
|
1119 |
// and set cursor position on the right place |
|
1120 |
ptr.Delete(illegalCharPos, 1); |
|
1121 |
CEikEdwin::SetTextL(res); |
|
1122 |
textChanged = ETrue; |
|
1123 |
if (cursorPos >= 1) |
|
1124 |
{ |
|
1125 |
if (cursorPos == illegalCharPos) |
|
1126 |
{ |
|
1127 |
cursorPos--; |
|
1128 |
} |
|
1129 |
endCursorPos = cursorPos; |
|
1130 |
} |
|
1131 |
} |
|
1132 |
CEikEdwin::SetCursorPosL(endCursorPos, EFalse); |
|
1133 |
CleanupStack::Pop(res); |
|
1134 |
delete res; |
|
1135 |
} |
|
1136 |
else if (((iConstraints & |
|
1137 |
MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr)|| |
|
1138 |
((iConstraints & |
|
1139 |
MMIDTextField::EConstraintMask) == MMIDTextField::EUrl)) |
|
1140 |
{ |
|
1141 |
HBufC* res = NULL; |
|
1142 |
TRAPD(err, { res = GetTextL();}); |
|
1143 |
if (err != KErrNone || !res) |
|
1144 |
{ |
|
1145 |
return; |
|
1146 |
} |
|
1147 |
CleanupStack::PushL(res); |
|
1148 |
||
1149 |
// In EMAIL and URL mode, don't allow changes that would result |
|
1150 |
// in an illegal string; if there is '/n' or '/f', and line breaks |
|
1151 |
// are not supported, chars need to be changed to space |
|
1152 |
// SetText function before actual text change checks if line |
|
1153 |
// breaks are not supported |
|
1154 |
TPtr16 text = res->Des(); |
|
1155 |
TInt tmpPos; |
|
1156 |
||
1157 |
if ((text.Locate(TChar('\n'))) >=0 || |
|
1158 |
(text.Locate(TChar('\f'))) >=0) |
|
1159 |
{ |
|
1160 |
tmpPos = CEikEdwin::CursorPos(); |
|
1161 |
SetTextL(*res); |
|
1162 |
CEikEdwin::SetCursorPosL(tmpPos, EFalse); |
|
1163 |
} |
|
1164 |
||
1165 |
textChanged = ETrue; |
|
1166 |
CleanupStack::Pop(res); |
|
1167 |
delete res; |
|
1168 |
} |
|
1169 |
||
1170 |
// if there were any modifications the text is updated |
|
1171 |
if (textChanged) |
|
1172 |
{ |
|
1173 |
HandleTextChangedL(); |
|
1174 |
} |
|
1175 |
} |
|
1176 |
||
1177 |
||
1178 |
} |
|
1179 |
||
1180 |
void CMIDEdwin::SetInitialInputModeL(const TDesC& aCharacterSubset) |
|
1181 |
{ |
|
1182 |
iEdwinUtils->SetInitialInputModeL(aCharacterSubset, |
|
1183 |
iConstraints, |
|
1184 |
iInitialCurrentCase, |
|
1185 |
iInitialCurrentInputMode, |
|
1186 |
iInitialCurrentLanguage); |
|
1187 |
||
1188 |
TUint constraint = iConstraints & MMIDTextField::EConstraintMask; |
|
1189 |
||
1190 |
// Set permitted case modes for TextBox in lowercase or uppercase mode. |
|
1191 |
if (aCharacterSubset.Compare(KMidpUppercaseLatin) == 0 || |
|
1192 |
aCharacterSubset.Compare(KMidpLowercaseLatin) == 0) |
|
1193 |
{ |
|
1194 |
//Setting permited case mode for TextField in ANY do panic |
|
1195 |
//when TextField loses focus. |
|
1196 |
if (iTextFieldItem && iConstraints == MMIDTextField::EAny) |
|
1197 |
{ |
|
1198 |
return; |
|
1199 |
} |
|
1200 |
// MIDP_UPPERCASE_LATIN or MIDP_LOWERCASE_LATIN are ignored if |
|
1201 |
// INITIAL_CAPS_SENTENCE or INITIAL_CAPS_WORD modifier in ANY. |
|
1202 |
if (!(iConstraints & MMIDTextField::EInitialCapsWordSentence || |
|
1203 |
iConstraints & MMIDTextField::EInitialCapsWord) || |
|
1204 |
constraint != MMIDTextField::EAny) |
|
1205 |
{ |
|
1206 |
// If initial input mode is uppercase or lowercase then permit |
|
1207 |
// only explicit case mode changes, automatic changes are not |
|
1208 |
// allowed. |
|
1209 |
SetAknEditorPermittedCaseModes(EAknEditorUpperCase | |
|
1210 |
EAknEditorLowerCase); |
|
1211 |
} |
|
1212 |
} |
|
1213 |
else |
|
1214 |
{ |
|
1215 |
SetAknEditorPermittedCaseModes(EAknEditorAllCaseModes); |
|
1216 |
} |
|
1217 |
||
1218 |
} |
|
1219 |
||
1220 |
||
1221 |
TBool CMIDEdwin::IsNumberConversionNeeded() |
|
1222 |
{ |
|
1223 |
return iEdwinUtils->IsNumberConversionNeeded(GetConstraints()); |
|
1224 |
} |
|
1225 |
||
1226 |
void CMIDEdwin::SetFEPModeAndCharFormat() |
|
1227 |
{ |
|
1228 |
iEdwinUtils->SetFEPModeAndCharFormat(iConstraints, this); |
|
1229 |
} |
|
1230 |
||
1231 |
/** Create non-midlet commands according to the constraints and add them |
|
1232 |
to either the displayable or to the item. Commands will be processed in ProcessCommandL(). */ |
|
1233 |
void CMIDEdwin::CreateNonMidletCommandsL() |
|
1234 |
{ |
|
1235 |
if (((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber) && !(iConstraints & MMIDTextField::EUneditable)) |
|
1236 |
{ |
|
1237 |
AddCommandToEdwinL(R_MIDP_PB_FETCH_NUMBER_SHORT_COMMAND_TEXT, R_MIDP_PB_FETCH_NUMBER_COMMAND_TEXT, CMIDEdwinUtils::EMenuCommandFetchPhoneNumber); |
|
1238 |
AddCommandToEdwinL(R_MIDP_CREATE_CALL_SHORT_COMMAND_TEXT, R_MIDP_CREATE_CALL_COMMAND_TEXT, CMIDEdwinUtils::EMenuCommandCreatePhoneCall); |
|
1239 |
} |
|
1240 |
||
1241 |
if (((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EPhoneNumber) && (iConstraints & MMIDTextField::EUneditable)) |
|
1242 |
{ |
|
1243 |
AddCommandToEdwinL(R_MIDP_CREATE_CALL_SHORT_COMMAND_TEXT, R_MIDP_CREATE_CALL_COMMAND_TEXT, CMIDEdwinUtils::EMenuCommandCreatePhoneCall); |
|
1244 |
} |
|
1245 |
||
1246 |
if (((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr) && !(iConstraints & MMIDTextField::EUneditable)) |
|
1247 |
{ |
|
1248 |
AddCommandToEdwinL(R_MIDP_PB_FETCH_EMAIL_SHORT_COMMAND_TEXT, R_MIDP_PB_FETCH_EMAIL_COMMAND_TEXT, CMIDEdwinUtils::EMenuCommandFetchEmailAddress); |
|
1249 |
} |
|
1250 |
} |
|
1251 |
||
1252 |
/** |
|
1253 |
Creates and adds new command to edwin based on shot & long label resource ids |
|
1254 |
and other parameters. |
|
1255 |
*/ |
|
1256 |
void CMIDEdwin::AddCommandToEdwinL(TInt aCommandResIdShort, |
|
1257 |
TInt aCommandResIdLong, |
|
1258 |
TInt aCommandId) |
|
1259 |
{ |
|
1260 |
TBuf<64> shortLabel; |
|
1261 |
iEikonEnv->ReadResourceL(shortLabel, aCommandResIdShort); |
|
1262 |
TBuf<64> longLabel; |
|
1263 |
iEikonEnv->ReadResourceL(longLabel, aCommandResIdLong); |
|
1264 |
||
1265 |
||
1266 |
MMIDCommand* cmd = CMIDCommand::NewL(shortLabel, longLabel, MMIDCommand::EItem, 0, aCommandId); |
|
1267 |
CleanupStack::PushL(cmd); |
|
1268 |
||
1269 |
STATIC_CAST(CMIDCommand*,cmd)->SetObserver(this); |
|
1270 |
||
1271 |
AddCommandToEdwinL(*cmd); |
|
1272 |
CleanupStack::Pop(cmd); |
|
1273 |
} |
|
1274 |
||
1275 |
/** |
|
1276 |
Creates and adds new command to edwin, short label is the same as long label. |
|
1277 |
*/ |
|
1278 |
void CMIDEdwin::AddCommandToEdwinL(TInt aCommandResId, TInt aCommandId) |
|
1279 |
{ |
|
1280 |
AddCommandToEdwinL(aCommandResId, aCommandResId, aCommandId); |
|
1281 |
} |
|
1282 |
||
1283 |
/** This method is called from the destructor and removes |
|
1284 |
the commands added by CreateNonMidletCommandsL(). To do |
|
1285 |
this we examine cmds on the list (either of the displayable |
|
1286 |
or the item as applicable) and remove those whose observer is us. |
|
1287 |
*/ |
|
1288 |
void CMIDEdwin::RemoveNonMidletCommands() |
|
1289 |
{ |
|
1290 |
CMIDCommandList* list = NULL; |
|
1291 |
if (iDisplayable) |
|
1292 |
{ |
|
1293 |
list = STATIC_CAST(CMIDDisplayable*, iDisplayable)->MainCommandList(); |
|
1294 |
} |
|
1295 |
else if (iTextFieldItem) |
|
1296 |
{ |
|
1297 |
list = STATIC_CAST(CMIDTextFieldItem*, iTextFieldItem)->CommandList(); |
|
1298 |
} |
|
1299 |
||
1300 |
if (!list) |
|
1301 |
{ |
|
1302 |
return; |
|
1303 |
} |
|
1304 |
||
1305 |
for (TInt i = 0; i < list->Count(); i++) |
|
1306 |
{ |
|
1307 |
CMIDCommand* cmd = list->At(i).iCommand; |
|
1308 |
if (cmd && (cmd->Observer() == this)) |
|
1309 |
{ |
|
1310 |
list->Remove(cmd); |
|
1311 |
cmd->Dispose(); |
|
1312 |
i--; |
|
1313 |
} |
|
1314 |
} |
|
1315 |
} |
|
1316 |
||
1317 |
/** Process non-midlet commands according to their unique negative id. See |
|
1318 |
MMIDCommandObserver, FetchFromPhoneBoolL() and CreateNonMidletCommandsL(). */ |
|
1319 |
TBool CMIDEdwin::ProcessCommandL(CMIDCommand* aCommand) |
|
1320 |
{ |
|
1321 |
ASSERT(aCommand); |
|
1322 |
TBool ret = EFalse; |
|
1323 |
||
1324 |
switch (aCommand->Id()) |
|
1325 |
{ |
|
1326 |
case CMIDEdwinUtils::EMenuCommandFetchPhoneNumber: |
|
1327 |
// for fetching data from phonebook |
|
1328 |
if (!iAiwPbkClient) |
|
1329 |
{ |
|
1330 |
iAiwPbkClient = CMIDAiwPbk2Client::NewL(*this); |
|
1331 |
} |
|
1332 |
iAiwPbkClient->FetchFromPhoneBookL(EAiwPhoneNumberSelect); |
|
1333 |
ret = ETrue; |
|
1334 |
break; |
|
1335 |
case CMIDEdwinUtils::EMenuCommandFetchEmailAddress: |
|
1336 |
// for fetching data from phonebook |
|
1337 |
if (!iAiwPbkClient) |
|
1338 |
{ |
|
1339 |
iAiwPbkClient = CMIDAiwPbk2Client::NewL(*this); |
|
1340 |
} |
|
1341 |
iAiwPbkClient->FetchFromPhoneBookL(EAiwEMailSelect); |
|
1342 |
ret = ETrue; |
|
1343 |
break; |
|
1344 |
case CMIDEdwinUtils::EMenuCommandCreatePhoneCall: |
|
1345 |
CreatePhoneCallL(); |
|
1346 |
ret = ETrue; |
|
1347 |
break; |
|
1348 |
default: |
|
1349 |
break; |
|
1350 |
} |
|
1351 |
||
1352 |
return ret; |
|
1353 |
} |
|
1354 |
||
1355 |
void CMIDEdwin::CreatePhoneCallL() |
|
1356 |
{ |
|
1357 |
iEdwinUtils->CreatePhoneCallL(TextLength(), CCoeEnv::Static()->WsSession(), this); |
|
1358 |
} |
|
1359 |
||
1360 |
/** From MTickerObserver: If the ticker is showing disable the displaying of |
|
1361 |
edit indicators in the navi pane. **/ |
|
1362 |
void CMIDEdwin::TickerShowing(TBool aShowing) |
|
1363 |
{ |
|
1364 |
TInt flags = aShowing ? EAknEditorFlagNoEditIndicators | AknEdwinFlags() : |
|
1365 |
~EAknEditorFlagNoEditIndicators & AknEdwinFlags(); |
|
1366 |
||
1367 |
SetAknEditorFlags(flags); |
|
1368 |
} |
|
1369 |
||
1370 |
void CMIDEdwin::HandleCurrentL(TBool aActivate) |
|
1371 |
{ |
|
1372 |
// when becoming the current Displayable, set editor input mode |
|
1373 |
// to the one set by SetInitialInputModeL |
|
1374 |
if (aActivate && |
|
1375 |
((iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EAny || |
|
1376 |
(iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr || |
|
1377 |
(iConstraints & MMIDTextField::EConstraintMask) == MMIDTextField::EUrl)) |
|
1378 |
{ |
|
1379 |
if (iInitialCurrentLanguage) |
|
1380 |
{ |
|
1381 |
SetAknEditorLocalLanguage(iInitialCurrentLanguage); |
|
1382 |
if (iInitialCurrentInputMode == 0) |
|
1383 |
{ |
|
1384 |
// clears any number mode used previously |
|
1385 |
SetAknEditorCurrentInputMode(EAknEditorNullInputMode); |
|
1386 |
} |
|
1387 |
} |
|
1388 |
||
1389 |
if (iInitialCurrentInputMode) |
|
1390 |
{ |
|
1391 |
SetAknEditorCurrentInputMode(iInitialCurrentInputMode); |
|
1392 |
} |
|
1393 |
||
1394 |
if (iInitialCurrentCase) |
|
1395 |
{ |
|
1396 |
TInt initialCurrentCase = iInitialCurrentCase; |
|
1397 |
if ((iConstraints & MMIDTextField::EPassword || |
|
1398 |
iConstraints & MMIDTextField::EMailAddr || |
|
1399 |
iConstraints & MMIDTextField::EUrl) && |
|
1400 |
iInitialCurrentCase == EAknEditorTextCase) |
|
1401 |
{ |
|
1402 |
// Text case is not used in passwords, emailaddrs and urls |
|
1403 |
initialCurrentCase = EAknEditorLowerCase; |
|
1404 |
} |
|
1405 |
SetAknEditorCurrentCase(initialCurrentCase); |
|
1406 |
SetAknEditorCase(initialCurrentCase); |
|
1407 |
} |
|
1408 |
} |
|
1409 |
if (aActivate) |
|
1410 |
{ |
|
1411 |
UpdateTextCapacityIndicatorValueL(); |
|
1412 |
} |
|
1413 |
} |
|
1414 |
||
1415 |
/** Update the text capacity indicator if we have focus and are not read only.*/ |
|
1416 |
void CMIDEdwin::UpdateTextCapacityIndicatorValueL() |
|
1417 |
{ |
|
1418 |
TBool isActive = iDisplayable ? iDisplayable->IsActive() : |
|
1419 |
(iTextFieldItem->Form() ? iTextFieldItem->Form()->CurrentDisplayable().IsActive() : EFalse); |
|
1420 |
||
1421 |
if (IsFocused() && isActive && !(iConstraints & MMIDTextField::EUneditable)) |
|
1422 |
{ |
|
1423 |
// Navi pane controller is opened on constructor phase so it should exists |
|
1424 |
iUIManager->OpenNaviPaneControllerL()->UpdateTextInputIndicatorL( |
|
1425 |
iMaxSize - TextLength()); |
|
1426 |
iDisplayingCapacityIndic = ETrue; |
|
1427 |
} |
|
1428 |
else if (iDisplayingCapacityIndic) |
|
1429 |
{ |
|
1430 |
// Navi pane controller is opened on constructor phase so it should exists |
|
1431 |
iUIManager->OpenNaviPaneControllerL()->UpdateTextInputIndicatorL(-1); |
|
1432 |
iDisplayingCapacityIndic = EFalse; |
|
1433 |
} |
|
1434 |
} |
|
1435 |
||
1436 |
/** Updates capacity indicator when text is pasted. */ |
|
1437 |
void CMIDEdwin::HandleTextPastedL(TInt aStartPos,TInt& aLength) |
|
1438 |
{ |
|
1439 |
// When TextBox field is NUMERIC, PHONENUMBER or DECIMAL new line |
|
1440 |
// characters if exists in copied text must be filtered out before pasting |
|
1441 |
||
1442 |
if ((IsConstraintSet(MMIDTextField::ENumeric) || |
|
1443 |
IsConstraintSet(MMIDTextField::EPhoneNumber) || |
|
1444 |
IsConstraintSet(MMIDTextField::EDecimal)) != EFalse) |
|
1445 |
{ |
|
1446 |
HBufC* hbuf = GetTextInHBufL(); |
|
1447 |
TPtr strPtr = hbuf->Des(); |
|
1448 |
TInt firstPos = strPtr.Find(KLineSeparator); |
|
1449 |
||
1450 |
if (firstPos != KErrNotFound) |
|
1451 |
{ |
|
1452 |
CleanupStack::PushL(hbuf); |
|
1453 |
while (firstPos != KErrNotFound) |
|
1454 |
{ |
|
1455 |
strPtr.Delete(firstPos, KLineSeparator().Length()); |
|
1456 |
firstPos = strPtr.Find(KLineSeparator); |
|
1457 |
} |
|
1458 |
CEikEdwin::SetTextL(hbuf); |
|
1459 |
CleanupStack::Pop(hbuf); |
|
1460 |
} |
|
1461 |
delete hbuf; |
|
1462 |
} |
|
1463 |
UpdateTextCapacityIndicatorValueL(); |
|
1464 |
CEikEdwin::HandleTextPastedL(aStartPos, aLength); |
|
1465 |
} |
|
1466 |
||
1467 |
TPtrC CMIDEdwin::Read() const |
|
1468 |
{ |
|
1469 |
if (iConstraints & MMIDTextField::EPassword) |
|
1470 |
{ |
|
1471 |
return static_cast<CPasswordBoxGlobalText*>(iText)->ClearText(); |
|
1472 |
} |
|
1473 |
else |
|
1474 |
{ |
|
1475 |
return iText->Read(0,TextLength()); |
|
1476 |
} |
|
1477 |
} |