44
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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:
|
|
15 |
* Provides the TAknFepUiInputStateEntryHalfQwertyWesternPredictive methods.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
#include "AknFepUiInputStateEntryHalfQwertyWesternPredictive.h"
|
|
31 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface
|
|
32 |
#include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface
|
|
33 |
#include "AknFepUiManagerWestern.h"
|
|
34 |
#include "AknFepManager.h"
|
|
35 |
#include "AknFepPanic.h"
|
|
36 |
#include "AknFepCaseManager.h"
|
|
37 |
|
|
38 |
#include <PtiEngine.h> //CPtiEngine
|
|
39 |
#include <PtiDefs.h> //keys
|
|
40 |
#include <PtiCompositionDataIF.h> //MPtiEngineCompositionDataInterface
|
|
41 |
#include <featmgr.h> //FeatureManager
|
|
42 |
#include <e32keys.h>
|
|
43 |
#include <aknfep.rsg>
|
|
44 |
#include <PtiUserDicEntry.h>
|
|
45 |
// TODO: Remove this include
|
|
46 |
#include <AvkonInternalCRKeys.h>
|
|
47 |
#include <AknUtils.h>
|
|
48 |
|
|
49 |
static const TInt KKeyMappingsLength = 63;
|
|
50 |
|
|
51 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
52 |
//
|
|
53 |
TAknFepUiInputStateEntryHalfQwertyWesternPredictive::TAknFepUiInputStateEntryHalfQwertyWesternPredictive(MAknFepUIManagerStateInterface* aOwner)
|
|
54 |
:TAknFepInputStateBase(aOwner)
|
|
55 |
{
|
|
56 |
//this class insists on the existence of a case manager
|
|
57 |
__ASSERT_DEBUG(iOwner->CaseMan(), AknFepPanic(EAknFepPanicNoCaseManager));
|
|
58 |
|
|
59 |
iState = EEntry;
|
|
60 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
61 |
|
|
62 |
ptiengine->SetInputMode( EPtiEngineHalfQwertyPredictive );
|
|
63 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
64 |
|
|
65 |
TPtiTextCase caseMode = ptiengine->Case();
|
|
66 |
|
|
67 |
ptiengine->SetCase(caseMode);
|
|
68 |
TBool isUnlimitedEditor = EFalse;
|
|
69 |
ptiengine->SetMaxLengthForAutoCompletedCandidates(fepMan->EditorFreeSpaceForAutoWordCompletion(isUnlimitedEditor ));
|
|
70 |
|
|
71 |
if(fepMan->IsAutoCompleteOn())
|
|
72 |
{
|
|
73 |
TRAP_IGNORE( ptiengine->HandleCommandL( EPtiCommandEnableAutoCompletion ) );
|
|
74 |
}
|
|
75 |
else
|
|
76 |
{
|
|
77 |
TRAP_IGNORE( ptiengine->HandleCommandL( EPtiCommandDisableAutoCompletion ) );
|
|
78 |
}
|
|
79 |
|
|
80 |
// TPtiErrorCorrectionLevel correctionLevel = (TPtiErrorCorrectionLevel)fepMan->AdvancedPredictiveTypingCorrectionLevel();
|
|
81 |
// TRAP_IGNORE( ptiengine->HandleCommandL( EPtiCommandSetCorrectionLevel, &correctionLevel ) );
|
|
82 |
|
|
83 |
TPtiKeyboardType keyboard = fepMan->KeyboardLayout();
|
|
84 |
ptiengine->SetKeyboardType(keyboard);
|
|
85 |
|
|
86 |
|
|
87 |
// TBool isNumberCandidateShown = fepMan->IsAdvancedPredictiveNumberCandidateShown();
|
|
88 |
// TRAP_IGNORE( ptiengine->HandleCommandL( EPtiCommandSetNumberCandidateStatus, &isNumberCandidateShown ) );
|
|
89 |
//
|
|
90 |
// TBool primaryCandidateState = fepMan->AdvancedPredictivePrimaryCandidate();
|
|
91 |
// TRAP_IGNORE( ptiengine->HandleCommandL( EPtiCommandSetProactiveCorrection, &primaryCandidateState ) );
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
96 |
//
|
|
97 |
TBool TAknFepUiInputStateEntryHalfQwertyWesternPredictive::HandleKeyL(TInt aKey, TKeyPressLength aLength)
|
|
98 |
{
|
|
99 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
100 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
101 |
|
|
102 |
CAknFepFnKeyManager::TFnKeyState fnKeyState = fepMan->FnKeyState();
|
|
103 |
|
|
104 |
if(fnKeyState != CAknFepFnKeyManager::EFnKeyNone)
|
|
105 |
{
|
|
106 |
ptiengine->SetCase(EPtiCaseFnLower);
|
|
107 |
}
|
|
108 |
|
|
109 |
// Handle the Chr cycling
|
|
110 |
if ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) && aKey !=EKeyBackspace)
|
|
111 |
{
|
|
112 |
// if the key has no accented characters mapped to it, then just block the event
|
|
113 |
TBuf<KKeyMappingsLength> keyMappings;
|
|
114 |
ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseChrLower );
|
|
115 |
if( keyMappings.Length() == 0 )
|
|
116 |
{
|
|
117 |
return EFalse;
|
|
118 |
}
|
|
119 |
// if there is a no matches indicator remove it
|
|
120 |
if ( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) && fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches))
|
|
121 |
{
|
|
122 |
fepMan->TryRemoveNoMatchesIndicatorL();
|
|
123 |
fepMan->UpdateCbaL(NULL);
|
|
124 |
}
|
|
125 |
// if there is an autocompletion part rip it off
|
|
126 |
fepMan->RemoveSuggestedAdvanceCompletionL();
|
|
127 |
|
|
128 |
// now if the editor has no free space just return
|
|
129 |
if ( !fepMan->EditorHasFreeSpace() )
|
|
130 |
{
|
|
131 |
return EFalse;
|
|
132 |
}
|
|
133 |
// if we are in inline editing, break the word
|
|
134 |
if( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
|
|
135 |
{
|
|
136 |
TPtrC selectedWord = ptiengine->CurrentWord();
|
|
137 |
if( ptiengine->CurrentWord() != KNullDesC)
|
|
138 |
{
|
|
139 |
fepMan->UpdateInlineEditL( selectedWord, selectedWord.Length() ); //selection.iAnchorPosition
|
|
140 |
ptiengine->CommitCurrentWord();
|
|
141 |
}
|
|
142 |
fepMan->TryCloseUiL();
|
|
143 |
}
|
|
144 |
|
|
145 |
if ( iData && (iData != aKey) )
|
|
146 |
{
|
|
147 |
// Chr key is still pressed down but character key was changed from previous one
|
|
148 |
// to new one. The previous character is committed and PtiEngine starts
|
|
149 |
// processing new key.
|
|
150 |
ptiengine->CancelTimerActivity();
|
|
151 |
}
|
|
152 |
fepMan->SetFlag( CAknFepManager::EFlagInsideMultitapInlineEditingTransaction );
|
|
153 |
}
|
|
154 |
|
|
155 |
TBool response = EFalse;
|
|
156 |
|
|
157 |
|
|
158 |
// Handle dead keys with space or backspace. These keys are not mapped in PtiEngine, so they cannot
|
|
159 |
// be handled there.
|
|
160 |
/* if ( ptiengine->HandleCommandL(EPtiCommandDeadKeyWaiting) == 1 )
|
|
161 |
{
|
|
162 |
if ( aKey == EStdKeyBackspace )
|
|
163 |
{
|
|
164 |
// Pending dead key is removed with backspace. No other characters are removed.
|
|
165 |
ptiengine->HandleCommandL(EPtiCommandGetAndClearDeadKeyRootChar);
|
|
166 |
response = ETrue;
|
|
167 |
}
|
|
168 |
else if ( aKey == EStdKeySpace )
|
|
169 |
{
|
|
170 |
// Dead key followed by space enters the dead key root character
|
|
171 |
TText deadRoot = ptiengine->HandleCommandL(EPtiCommandGetAndClearDeadKeyRootChar);
|
|
172 |
ptiengine->HandleCommandL( EPtiCommandAppendCharacter, &deadRoot );
|
|
173 |
|
|
174 |
TPtrC newText = ptiengine->CurrentWord();
|
|
175 |
fepMan->UpdateInlineEditL( newText, newText.Length() );
|
|
176 |
iOwner->CaseMan()->UpdateCase(ENullNaviEvent);
|
|
177 |
|
|
178 |
response = ETrue;
|
|
179 |
}
|
|
180 |
}
|
|
181 |
*/
|
|
182 |
if (!response) // key not yet handled
|
|
183 |
{
|
|
184 |
switch (aKey)
|
|
185 |
{
|
|
186 |
case EStdKeySpace:
|
|
187 |
if( fepMan->FnKeyState()
|
|
188 |
== CAknFepFnKeyManager::EFnKeyNone )
|
|
189 |
{
|
|
190 |
response = HandleWordBreakingKeysL(aKey);
|
|
191 |
}
|
|
192 |
else
|
|
193 |
{
|
|
194 |
response = HandleQwertyKeysL( aKey, aLength);
|
|
195 |
}
|
|
196 |
break;
|
|
197 |
case EStdKeyFullStop:
|
|
198 |
if( aLength == ELongKeyPress )
|
|
199 |
{
|
|
200 |
// first commit the word if in inline editing
|
|
201 |
if( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
|
|
202 |
{
|
|
203 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches))
|
|
204 |
{
|
|
205 |
fepMan->TryRemoveNoMatchesIndicatorL();
|
|
206 |
fepMan->UpdateCbaL(NULL);
|
|
207 |
}
|
|
208 |
|
|
209 |
TPtrC selectedWord = ptiengine->CurrentWord();
|
|
210 |
if( ptiengine->CurrentWord() != KNullDesC)
|
|
211 |
{
|
|
212 |
fepMan->UpdateInlineEditL( selectedWord, selectedWord.Length() ); //selection.iAnchorPosition
|
|
213 |
ptiengine->CommitCurrentWord();
|
|
214 |
}
|
|
215 |
fepMan->TryCloseUiL();
|
|
216 |
}
|
|
217 |
response = EFalse;
|
|
218 |
}
|
|
219 |
else
|
|
220 |
{
|
|
221 |
HandleShiftState(aKey);
|
|
222 |
response = HandleQwertyKeysL( aKey, aLength);
|
|
223 |
}
|
|
224 |
break;
|
|
225 |
case EStdKeyEnter:
|
|
226 |
case EStdKeyTab:
|
|
227 |
case EStdKeyLeftArrow:
|
|
228 |
case EStdKeyRightArrow:
|
|
229 |
case EStdKeyUpArrow:
|
|
230 |
case EStdKeyDownArrow:
|
|
231 |
response = HandleWordBreakingKeysL(aKey);
|
|
232 |
break;
|
|
233 |
|
|
234 |
// Long press of shift key start copy event.
|
|
235 |
// Its should handle by framework.
|
|
236 |
case EStdKeyF21:
|
|
237 |
case EKeyF21:
|
|
238 |
// Soft key handle by framework
|
|
239 |
// Selection key handle by AknFepManager.
|
|
240 |
case EStdKeyDevice0: // iCode:EKeyCBA1
|
|
241 |
case EStdKeyDevice1: // iCode:EKeyCBA2
|
|
242 |
case EStdKeyDevice3: // iCode:EKeyOK
|
|
243 |
case EKeyCBA1:
|
|
244 |
case EKeyCBA2:
|
|
245 |
case EKeyOK:
|
|
246 |
response = EFalse;
|
|
247 |
break;
|
|
248 |
|
|
249 |
case EKeyUpArrow:
|
|
250 |
if ( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
|
|
251 |
{
|
|
252 |
// Select the exact match with the up arrow and lock it.
|
|
253 |
// Another alternative could be to call function DoPreviousMatchL() from here
|
|
254 |
|
|
255 |
TPtrC exactWord = ptiengine->FirstCandidate();
|
|
256 |
ptiengine->HandleCommandL( EPtiCommandLockCurrentCandidate, NULL );
|
|
257 |
|
|
258 |
fepMan->UpdateInlineEditL(exactWord, exactWord.Length());
|
|
259 |
|
|
260 |
response = ETrue;
|
|
261 |
break;
|
|
262 |
}
|
|
263 |
// fall through
|
|
264 |
case EKeyDownArrow:
|
|
265 |
case EKeyLeftArrow:
|
|
266 |
case EKeyRightArrow:
|
|
267 |
case EKeyBackspace:
|
|
268 |
{
|
|
269 |
response = HandleNaviKeysL(aKey, aLength);
|
|
270 |
}
|
|
271 |
break;
|
|
272 |
|
|
273 |
case EStdKeyLeftShift:
|
|
274 |
case EStdKeyRightShift:
|
|
275 |
case EStdKeyLeftFunc:
|
|
276 |
{
|
|
277 |
if( EPtiCaseFnLower == fepMan->PtiEngine()->Case() )
|
|
278 |
{
|
|
279 |
if ( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
|
|
280 |
{
|
|
281 |
fepMan->TryRemoveNoMatchesIndicatorL();
|
|
282 |
}
|
|
283 |
|
|
284 |
fepMan->UpdateCbaL(NULL);
|
|
285 |
|
|
286 |
/*if (fepMan->IsFlagSet(CAknFepManager::EFlagCompoundWord))
|
|
287 |
{
|
|
288 |
if (fepMan->IsCursorAtEndOfWord())
|
|
289 |
{
|
|
290 |
fepMan->AddCompoundWordToUdbL();
|
|
291 |
}
|
|
292 |
fepMan->ClearFlag(CAknFepManager::EFlagCompoundWord);
|
|
293 |
}
|
|
294 |
*/
|
|
295 |
|
|
296 |
fepMan->RemoveSuggestedAdvanceCompletionL();
|
|
297 |
ptiengine->CommitCurrentWord();
|
|
298 |
fepMan->CommitInlineEditL();
|
|
299 |
fepMan->TryCloseUiL();
|
|
300 |
response = EFalse;
|
|
301 |
}
|
|
302 |
}
|
|
303 |
break;
|
|
304 |
|
|
305 |
default:
|
|
306 |
HandleShiftState(aKey);
|
|
307 |
response = HandleQwertyKeysL(aKey, aLength);
|
|
308 |
#ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
|
|
309 |
if ( aLength == ELongKeyPress )
|
|
310 |
{
|
|
311 |
// Expire multitap timer after long press.
|
|
312 |
ptiengine->CancelTimerActivity();
|
|
313 |
}
|
|
314 |
#endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
|
|
315 |
break;
|
|
316 |
}
|
|
317 |
}
|
|
318 |
|
|
319 |
if ( aKey == EStdKeyEnter)
|
|
320 |
{
|
|
321 |
iData = 0;
|
|
322 |
return 0;
|
|
323 |
}
|
|
324 |
|
|
325 |
if (!iOwner->PtiEngine()->IsValidKey((TPtiKey)aKey))
|
|
326 |
{
|
|
327 |
iData = 0;
|
|
328 |
fepMan->ClearFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
|
|
329 |
fepMan->PtiEngine()->CancelTimerActivity();
|
|
330 |
|
|
331 |
return response;
|
|
332 |
}
|
|
333 |
|
|
334 |
|
|
335 |
iData = aKey; // store the pressed key for future reference
|
|
336 |
return response;
|
|
337 |
}
|
|
338 |
|
|
339 |
|
|
340 |
//////////////////////////////////////////////////////////////////////////////////
|
|
341 |
//
|
|
342 |
void TAknFepUiInputStateEntryHalfQwertyWesternPredictive::HandleShiftState( TInt aKey )
|
|
343 |
{
|
|
344 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
345 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
346 |
CAknFepCaseManager* caseMan = iOwner->CaseMan();
|
|
347 |
CAknFepFnKeyManager::TFnKeyState fnKeyState = fepMan->FnKeyState();
|
|
348 |
TPtiTextCase shiftedCase;
|
|
349 |
if(fnKeyState != CAknFepFnKeyManager::EFnKeyNone)
|
|
350 |
{
|
|
351 |
shiftedCase = EPtiCaseFnLower;
|
|
352 |
}
|
|
353 |
else
|
|
354 |
{
|
|
355 |
shiftedCase= EPtiCaseLower;
|
|
356 |
}
|
|
357 |
|
|
358 |
// Find out if the key is alphabetic
|
|
359 |
TBuf<KKeyMappingsLength> keyMappings;
|
|
360 |
ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseUpper );
|
|
361 |
TBool isAlpha = ( keyMappings.Length() && TChar(keyMappings[0]).IsAlpha() );
|
|
362 |
|
|
363 |
if (isAlpha && (fnKeyState == CAknFepFnKeyManager::EFnKeyNone))
|
|
364 |
{
|
|
365 |
switch ( caseMan->CurrentCase() )
|
|
366 |
{
|
|
367 |
case EAknEditorTextCase:
|
|
368 |
{
|
|
369 |
// Alphabetic characters are always capitalized in "Abc" mode
|
|
370 |
// unless the shift is pressed
|
|
371 |
if ( !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) )
|
|
372 |
{
|
|
373 |
shiftedCase = EPtiCaseUpper;
|
|
374 |
}
|
|
375 |
}
|
|
376 |
break;
|
|
377 |
|
|
378 |
case EAknEditorLowerCase:
|
|
379 |
{
|
|
380 |
// Pressing shift enters uppercae letters in the "abc" mode
|
|
381 |
if ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) )
|
|
382 |
{
|
|
383 |
shiftedCase = EPtiCaseUpper;
|
|
384 |
}
|
|
385 |
}
|
|
386 |
break;
|
|
387 |
|
|
388 |
case EAknEditorUpperCase:
|
|
389 |
{
|
|
390 |
// In the "ABC" mode (capslock mode) the letters are uppercased
|
|
391 |
// unless the shift is pressed
|
|
392 |
if ( !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) )
|
|
393 |
{
|
|
394 |
shiftedCase = EPtiCaseUpper;
|
|
395 |
}
|
|
396 |
}
|
|
397 |
break;
|
|
398 |
|
|
399 |
default:
|
|
400 |
break;
|
|
401 |
}
|
|
402 |
|
|
403 |
|
|
404 |
}
|
|
405 |
else
|
|
406 |
{
|
|
407 |
// non-alphabetic keys are shifted if and only if shift is pressed, no matter what is the input state
|
|
408 |
if ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) && (fnKeyState == CAknFepFnKeyManager::EFnKeyNone))
|
|
409 |
{
|
|
410 |
shiftedCase = EPtiCaseUpper;
|
|
411 |
}
|
|
412 |
else if ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) && (fnKeyState != CAknFepFnKeyManager::EFnKeyNone))
|
|
413 |
{
|
|
414 |
shiftedCase = EPtiCaseFnUpper;
|
|
415 |
}
|
|
416 |
}
|
|
417 |
|
|
418 |
|
|
419 |
// Handle the Chr key state
|
|
420 |
if ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) )
|
|
421 |
{
|
|
422 |
// Chr key is pressed down. Chr mode is used.
|
|
423 |
if (shiftedCase == EPtiCaseLower)
|
|
424 |
{
|
|
425 |
shiftedCase = EPtiCaseChrLower;
|
|
426 |
}
|
|
427 |
else if (shiftedCase == EPtiCaseUpper)
|
|
428 |
{
|
|
429 |
shiftedCase = EPtiCaseChrUpper;
|
|
430 |
}
|
|
431 |
}
|
|
432 |
|
|
433 |
ptiengine->SetCase(shiftedCase);
|
|
434 |
|
|
435 |
fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringShiftKeyPress);
|
|
436 |
}
|
|
437 |
|
|
438 |
//////////////////////////////////////////////////////////////////////////////////
|
|
439 |
//
|
|
440 |
|
|
441 |
TBool TAknFepUiInputStateEntryHalfQwertyWesternPredictive::HandleWordBreakingKeysL(TInt aKey)
|
|
442 |
{
|
|
443 |
TBool retVal = EFalse; // in most cases we let also the upper levels handle these key events
|
|
444 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
445 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
446 |
|
|
447 |
|
|
448 |
// Up and down arrows break the inline word input only when shift or chr is held down
|
|
449 |
if ( !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) &&
|
|
450 |
!fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) &&
|
|
451 |
( aKey==EStdKeyUpArrow || aKey==EStdKeyDownArrow ) )
|
|
452 |
{
|
|
453 |
return retVal;
|
|
454 |
}
|
|
455 |
|
|
456 |
|
|
457 |
if ( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
|
|
458 |
{
|
|
459 |
TBool rightToLeftLang = fepMan->IsRightToLeftLanguage();
|
|
460 |
TInt tailLength = 0;
|
|
461 |
ptiengine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
|
|
462 |
switch (aKey)
|
|
463 |
{
|
|
464 |
case EStdKeyLeftArrow:
|
|
465 |
case EStdKeyRightArrow:
|
|
466 |
// In case the inline editing is ongoing and there is a word completion
|
|
467 |
// currently shown, the first backwards tap will remove the suggested
|
|
468 |
// completion.
|
|
469 |
if(tailLength > 0)
|
|
470 |
{
|
|
471 |
if ((rightToLeftLang && aKey == EStdKeyLeftArrow)
|
|
472 |
|| (! rightToLeftLang && aKey == EStdKeyRightArrow ))
|
|
473 |
{
|
|
474 |
ptiengine->HandleCommandL( EPtiCommandLockCurrentCandidate);
|
|
475 |
TPtrC selectedWord = ptiengine->CurrentWord();
|
|
476 |
fepMan->UpdateInlineEditL( selectedWord, selectedWord.Length() ); //selection.iAnchorPosition
|
|
477 |
// To fix Suggested word is not committed when Arrow right key is pressed.
|
|
478 |
ptiengine->CommitCurrentWord();
|
|
479 |
fepMan->TryCloseUiL();
|
|
480 |
// Asyncronous case update after the editor has handled the key
|
|
481 |
fepMan->SimulateKeyEventL(EKeyF19);
|
|
482 |
retVal = ETrue;
|
|
483 |
}
|
|
484 |
else if((rightToLeftLang && aKey == EStdKeyRightArrow)
|
|
485 |
|| (! rightToLeftLang && aKey == EStdKeyLeftArrow ))
|
|
486 |
{
|
|
487 |
fepMan->RemoveSuggestedAdvanceCompletionL();
|
|
488 |
retVal = ETrue;
|
|
489 |
}
|
|
490 |
}
|
|
491 |
else
|
|
492 |
{
|
|
493 |
ptiengine->CommitCurrentWord();
|
|
494 |
retVal = EFalse;
|
|
495 |
}
|
|
496 |
break;
|
|
497 |
case EStdKeyUpArrow:
|
|
498 |
case EStdKeyDownArrow:
|
|
499 |
case EStdKeyEnter:
|
|
500 |
case EStdKeySpace:
|
|
501 |
case EStdKeyTab:
|
|
502 |
{
|
|
503 |
//retVal = ETrue;
|
|
504 |
|
|
505 |
if ( ( aKey == EStdKeySpace || aKey == EStdKeyEnter ||aKey == EStdKeyTab)
|
|
506 |
&& fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)
|
|
507 |
&& (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches)) )
|
|
508 |
{
|
|
509 |
fepMan->TryRemoveNoMatchesIndicatorL();
|
|
510 |
fepMan->UpdateCbaL(NULL);
|
|
511 |
}
|
|
512 |
|
|
513 |
TBool wasInlineEditing = EFalse;
|
|
514 |
wasInlineEditing = fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction);
|
|
515 |
ptiengine->CommitCurrentWord();
|
|
516 |
fepMan->CommitInlineEditL();
|
|
517 |
/* Temporary Fix */
|
|
518 |
//EFlagInsideInlineEditingTransaction flag check is not required
|
|
519 |
//but just to make sure.
|
|
520 |
if(aKey == EStdKeySpace && wasInlineEditing)
|
|
521 |
{
|
|
522 |
_LIT(KSpace," ");
|
|
523 |
fepMan->StartInlineEditL();
|
|
524 |
fepMan->UpdateInlineEditL(KSpace,0);
|
|
525 |
fepMan->CommitInlineEditL();
|
|
526 |
retVal = ETrue;
|
|
527 |
}
|
|
528 |
/* Temporary Fix */
|
|
529 |
fepMan->TryCloseUiL();
|
|
530 |
// Asyncronous case update after the editor has handled the key
|
|
531 |
fepMan->SimulateKeyEventL(EKeyF19);
|
|
532 |
}
|
|
533 |
break;
|
|
534 |
default:
|
|
535 |
__ASSERT_DEBUG( EFalse, AknFepPanic(EAknFepPanicNotSupportKey) );
|
|
536 |
}
|
|
537 |
|
|
538 |
}
|
|
539 |
else
|
|
540 |
{
|
|
541 |
iOwner->ChangeState( EInitial );
|
|
542 |
}
|
|
543 |
|
|
544 |
return retVal;
|
|
545 |
}
|
|
546 |
|
|
547 |
|
|
548 |
/////////////////////////////////////////////////////////////////////////////////
|
|
549 |
//
|
|
550 |
TBool TAknFepUiInputStateEntryHalfQwertyWesternPredictive::HandleQwertyKeysL(TInt aKey, TKeyPressLength aLength)
|
|
551 |
{
|
|
552 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
553 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
554 |
TBool retVal = EFalse;
|
|
555 |
CAknFepCaseManager* caseMan = iOwner->CaseMan();
|
|
556 |
|
|
557 |
CAknFepFnKeyManager::TFnKeyState fnKeyState = fepMan->FnKeyState();
|
|
558 |
|
|
559 |
// Key is consumed if the PtiEngine maps it to some character
|
|
560 |
TBuf<KKeyMappingsLength> keyMappings;
|
|
561 |
|
|
562 |
if(fnKeyState != CAknFepFnKeyManager::EFnKeyNone)
|
|
563 |
{
|
|
564 |
ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseFnLower);
|
|
565 |
}
|
|
566 |
else
|
|
567 |
{
|
|
568 |
ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseLower);
|
|
569 |
}
|
|
570 |
//ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseLower);
|
|
571 |
//ITI : Pti Engine can be asked to give the proper data for the keys under Fn Key.
|
|
572 |
TBool keyIsMapped = ( keyMappings.Length() > 0 );
|
|
573 |
|
|
574 |
// The dead key handling inside the PtiDefaultCore assumes that no other key mapping queries
|
|
575 |
// have been made between handling the dead key and the next one (these queries change the
|
|
576 |
// internal state of the key mapping object). For this reason, we must return the key mappings
|
|
577 |
// to their previous state. This is quite dirty hack, but so is the dead key handling code which
|
|
578 |
// forces us to do this.
|
|
579 |
if(fnKeyState != CAknFepFnKeyManager::EFnKeyNone)
|
|
580 |
{
|
|
581 |
ptiengine->MappingDataForKey( (TPtiKey)iData, keyMappings, EPtiCaseFnLower);
|
|
582 |
}
|
|
583 |
else
|
|
584 |
{
|
|
585 |
ptiengine->MappingDataForKey( (TPtiKey)iData, keyMappings, EPtiCaseLower);
|
|
586 |
}
|
|
587 |
|
|
588 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches) && fnKeyState == CAknFepFnKeyManager::EFnKeyNone )
|
|
589 |
{
|
|
590 |
//no matches, so just play tone
|
|
591 |
fepMan->PlaySound(EAvkonSIDConfirmationTone);
|
|
592 |
return keyIsMapped;
|
|
593 |
}
|
|
594 |
|
|
595 |
if ( keyIsMapped )
|
|
596 |
{
|
|
597 |
if( fnKeyState != CAknFepFnKeyManager::EFnKeyNone )
|
|
598 |
{
|
|
599 |
//closing the UI will commit the current word and move to intial state
|
|
600 |
|
|
601 |
// break the word
|
|
602 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches))
|
|
603 |
{
|
|
604 |
fepMan->TryRemoveNoMatchesIndicatorL();
|
|
605 |
}
|
|
606 |
fepMan->RemoveSuggestedAdvanceCompletionL();
|
|
607 |
TPtrC selectedWord = ptiengine->CurrentWord();
|
|
608 |
if( ptiengine->CurrentWord() != KNullDesC)
|
|
609 |
{
|
|
610 |
fepMan->UpdateInlineEditL( selectedWord, selectedWord.Length() ); //selection.iAnchorPosition
|
|
611 |
ptiengine->CommitCurrentWord();
|
|
612 |
}
|
|
613 |
fepMan->TryCloseUiL();
|
|
614 |
ptiengine->SetCase(EPtiCaseFnLower);
|
|
615 |
}
|
|
616 |
|
|
617 |
if ( !(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) )
|
|
618 |
{ // 'new' inline edit
|
|
619 |
ptiengine->ClearCurrentWord();
|
|
620 |
if (caseMan->CurrentCase() == EAknEditorTextCase)
|
|
621 |
{
|
|
622 |
ptiengine->MarkAutoCapitalized();
|
|
623 |
}
|
|
624 |
|
|
625 |
fepMan->StartInlineEditL();
|
|
626 |
}
|
|
627 |
|
|
628 |
TPtrC newText;
|
|
629 |
|
|
630 |
if( aKey == EStdKeyFullStop )
|
|
631 |
{
|
|
632 |
TInt tailLength = 0;
|
|
633 |
ptiengine->HandleCommandL( EPtiCommandLockCurrentCandidate, &tailLength );
|
|
634 |
/* if( fepMan->IsAutoCompleteOn() )
|
|
635 |
{
|
|
636 |
TInt tailLength = 0;
|
|
637 |
ptiengine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
|
|
638 |
if( tailLength > 0)
|
|
639 |
{
|
|
640 |
// if autoword part is visible update the input sequence
|
|
641 |
newText.Set(ptiengine->CurrentWord() );
|
|
642 |
ptiengine->ClearCurrentWord();
|
|
643 |
ptiengine->SetCurrentWord(newText);
|
|
644 |
}
|
|
645 |
}*/
|
|
646 |
}
|
|
647 |
|
|
648 |
newText.Set(ptiengine->AppendKeyPress((TPtiKey)aKey));
|
|
649 |
|
|
650 |
if ( aLength == EShortKeyPress )
|
|
651 |
{
|
|
652 |
SetShortKeyPressText(newText);
|
|
653 |
}
|
|
654 |
if (ptiengine->NumberOfCandidates() > 0 )
|
|
655 |
{
|
|
656 |
// more good words coming in from predictive text engine so carry on
|
|
657 |
if(newText.Length() == 1)
|
|
658 |
{
|
|
659 |
TDigitType digittype = fepMan->LocalDigit();
|
|
660 |
TChar chchar(newText[0]);
|
|
661 |
if(!chchar.IsDigit() || (chchar.IsDigit() && !digittype))
|
|
662 |
{
|
|
663 |
fepMan->UpdateInlineEditL(newText, newText.Length());
|
|
664 |
}
|
|
665 |
else
|
|
666 |
{
|
|
667 |
TBuf<1> tempbuf;
|
|
668 |
tempbuf.Append(newText[0]);
|
|
669 |
ConvertDigitToDigittype(digittype,tempbuf);
|
|
670 |
fepMan->UpdateInlineEditL(tempbuf, tempbuf.Length());
|
|
671 |
}
|
|
672 |
if(fnKeyState != CAknFepFnKeyManager::EFnKeyNone)
|
|
673 |
{
|
|
674 |
ptiengine->CommitCurrentWord();
|
|
675 |
fepMan->CommitInlineEditL();
|
|
676 |
}
|
|
677 |
}
|
|
678 |
else
|
|
679 |
{
|
|
680 |
fepMan->UpdateInlineEditL(newText, newText.Length());
|
|
681 |
}
|
|
682 |
|
|
683 |
}
|
|
684 |
|
|
685 |
else
|
|
686 |
{
|
|
687 |
// engine has run out of matches
|
|
688 |
// we are not in the functionized state
|
|
689 |
fepMan->SetFlag(CAknFepManager::EFlagRemoveMatchesMenuItem);
|
|
690 |
fepMan->SetFlag(CAknFepManager::EFlagNoMatches);
|
|
691 |
fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_EMPTY);
|
|
692 |
if(newText.Length() == 1)
|
|
693 |
{
|
|
694 |
TDigitType digittype = fepMan->LocalDigit();
|
|
695 |
TChar chchar(newText[0]);
|
|
696 |
if(!chchar.IsDigit() || (chchar.IsDigit() && !digittype))
|
|
697 |
{
|
|
698 |
fepMan->UpdateInlineEditL(newText, newText.Length());
|
|
699 |
}
|
|
700 |
else
|
|
701 |
{
|
|
702 |
TBuf<1> tempbuf;
|
|
703 |
tempbuf.Append(newText[0]);
|
|
704 |
ConvertDigitToDigittype(digittype,tempbuf);
|
|
705 |
fepMan->UpdateInlineEditL(tempbuf, tempbuf.Length());
|
|
706 |
}
|
|
707 |
}
|
|
708 |
else
|
|
709 |
{
|
|
710 |
// Remove the autocompletion tail if present
|
|
711 |
if (fepMan->IsAutoCompleteOn())
|
|
712 |
{
|
|
713 |
TInt tailLength = 0;
|
|
714 |
ptiengine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
|
|
715 |
if(tailLength > 0)
|
|
716 |
{
|
|
717 |
// To remove the autocompletion part, the below function is used.
|
|
718 |
// DeleteKeyPress was used earlier. This is removed to fix the bug :
|
|
719 |
// enter characters to show autocompletion part. Now press a
|
|
720 |
// character so that the no matches character is shown. Now press
|
|
721 |
// backspace key, last character is not deleted.
|
|
722 |
fepMan->RemoveSuggestedAdvanceCompletionL();
|
|
723 |
fepMan->PlaySound(EAvkonSIDConfirmationTone);
|
|
724 |
return ETrue;
|
|
725 |
}
|
|
726 |
}
|
|
727 |
fepMan->UpdateInlineEditL(newText, newText.Length());
|
|
728 |
}
|
|
729 |
fepMan->PlaySound(EAvkonSIDConfirmationTone);
|
|
730 |
}
|
|
731 |
|
|
732 |
// Normally we update the case after key press. However, if Chr key is held down, the case update
|
|
733 |
// must not happen until when the Chr is released or the timer expires (in both of these cases
|
|
734 |
// the function KeyTimerExpired() will get callled).
|
|
735 |
if ( !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) )
|
|
736 |
{
|
|
737 |
iOwner->CaseMan()->UpdateCase(ENullNaviEvent);
|
|
738 |
}
|
|
739 |
else
|
|
740 |
{
|
|
741 |
fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringChrKeyPress);
|
|
742 |
}
|
|
743 |
|
|
744 |
retVal = ETrue;
|
|
745 |
}
|
|
746 |
else
|
|
747 |
{
|
|
748 |
retVal = EFalse;
|
|
749 |
}
|
|
750 |
|
|
751 |
if(ptiengine->IsValidKey((TPtiKey)aKey))
|
|
752 |
retVal = ETrue;
|
|
753 |
|
|
754 |
if( aKey!=EStdKeyBackspace && fnKeyState != CAknFepFnKeyManager::EFnKeyNone)
|
|
755 |
{
|
|
756 |
retVal = ETrue;
|
|
757 |
}
|
|
758 |
if( !fepMan->IsFlagSet( CAknFepManager::EFlagLongShiftKeyPress ) &&
|
|
759 |
fnKeyState == CAknFepFnKeyManager::EFnKeyNext )
|
|
760 |
{
|
|
761 |
fepMan->SetFnKeyState(CAknFepFnKeyManager::EFnKeyNone);
|
|
762 |
}
|
|
763 |
|
|
764 |
return retVal;
|
|
765 |
}
|
|
766 |
|
|
767 |
|
|
768 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
769 |
//
|
|
770 |
TBool TAknFepUiInputStateEntryHalfQwertyWesternPredictive::HandleNaviKeysL(TInt aKey, TKeyPressLength /*aLength*/)
|
|
771 |
{
|
|
772 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
773 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
774 |
|
|
775 |
if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
|
|
776 |
{
|
|
777 |
TBuf<CAknFepManager::EMaximumFepWordLength> textToUncommit;
|
|
778 |
TBool comsumeKey;
|
|
779 |
if (!(fepMan->TryGetTextToUncommitL(textToUncommit, aKey, comsumeKey)))
|
|
780 |
{
|
|
781 |
// If T9 word length > 32, the navi key is consumed without action.
|
|
782 |
// Maybe should navigate inside word.
|
|
783 |
return comsumeKey;
|
|
784 |
}
|
|
785 |
ptiengine->ClearCurrentWord();
|
|
786 |
ptiengine->SetCurrentWord(textToUncommit); // this set the input sequence of PtiEngine
|
|
787 |
fepMan->StartInlineEditL(fepMan->UncommittedText(), textToUncommit,
|
|
788 |
textToUncommit.Length(), EFalse);
|
|
789 |
}
|
|
790 |
|
|
791 |
if (aKey == EKeyBackspace)
|
|
792 |
{
|
|
793 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches))
|
|
794 |
{
|
|
795 |
fepMan->TryRemoveNoMatchesIndicatorL();
|
|
796 |
fepMan->UpdateCbaL(NULL);
|
|
797 |
ptiengine->HandleCommandL(EPtiCommandSetFlagToUpdateCandidates);
|
|
798 |
// Need to return as DeleteKeyPress should not be passed to ptiengine.
|
|
799 |
// This is because ptiengine does not maintain the input sequence
|
|
800 |
// if the key press does not increase the word length. So when no matches
|
|
801 |
// character is (?) is deleted, no need to pass to ptiengine. This is to done
|
|
802 |
// to solve the bug :enter characters till the no matches character is shown. Now press
|
|
803 |
// backspace, last character is not deleted.
|
|
804 |
return ETrue;
|
|
805 |
}
|
|
806 |
|
|
807 |
TPtrC newText = ptiengine->DeleteKeyPress();
|
|
808 |
// remove autocompletion part if any
|
|
809 |
// this has to be done before updateinlineedit to avoid flickering
|
|
810 |
TInt tailLength = 0;
|
|
811 |
ptiengine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength,
|
|
812 |
&tailLength );
|
|
813 |
if(tailLength > 0)
|
|
814 |
{
|
|
815 |
fepMan->RemoveSuggestedAdvanceCompletionL();
|
|
816 |
newText.Set(ptiengine->CurrentWord());
|
|
817 |
}
|
|
818 |
fepMan->UpdateInlineEditL(newText, newText.Length());
|
|
819 |
|
|
820 |
fepMan->ClearFlag(CAknFepManager::EFlagRemoveMatchesMenuItem);
|
|
821 |
if (ptiengine->NumberOfCandidates() <= 1)
|
|
822 |
{
|
|
823 |
fepMan->SetFlag(CAknFepManager::EFlagRemoveMatchesMenuItem);
|
|
824 |
}
|
|
825 |
|
|
826 |
iOwner->CaseMan()->UpdateCase(EBackspaceEvent);
|
|
827 |
fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringChrKeyPress);
|
|
828 |
fepMan->CloseUiIfWordDeletedL();
|
|
829 |
}
|
|
830 |
|
|
831 |
return ETrue;
|
|
832 |
}
|
|
833 |
|
|
834 |
|
|
835 |
/////////////////////////////////////////////////////////////////////////////
|
|
836 |
//
|
|
837 |
void TAknFepUiInputStateEntryHalfQwertyWesternPredictive::LastWordInSelectionList()
|
|
838 |
{
|
|
839 |
|
|
840 |
}
|
|
841 |
|
|
842 |
|
|
843 |
//////////////////////////////////////////////////////////////////////////////
|
|
844 |
//
|
|
845 |
void TAknFepUiInputStateEntryHalfQwertyWesternPredictive::FirstWordInSelectionList()
|
|
846 |
{
|
|
847 |
}
|
|
848 |
|
|
849 |
|
|
850 |
/////////////////////////////////////////////////////////////////
|
|
851 |
//
|
|
852 |
void TAknFepUiInputStateEntryHalfQwertyWesternPredictive::KeyTimerExpired()
|
|
853 |
{
|
|
854 |
if (iData)
|
|
855 |
{
|
|
856 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
857 |
CAknFepCaseManager* caseMan = iOwner->CaseMan();
|
|
858 |
caseMan->UpdateCase(ENullNaviEvent);
|
|
859 |
fepMan->ClearFlag( CAknFepManager::EFlagInsideMultitapInlineEditingTransaction );
|
|
860 |
iData = 0;
|
|
861 |
}
|
|
862 |
}
|
|
863 |
|
|
864 |
void TAknFepUiInputStateEntryHalfQwertyWesternPredictive::ConvertDigitToDigittype(TDigitType& digittype,TDes& aConvertedNumeral)
|
|
865 |
{
|
|
866 |
TChar chchar(aConvertedNumeral[0]);
|
|
867 |
switch(digittype)
|
|
868 |
{
|
|
869 |
case EDigitTypeDevanagari:
|
|
870 |
{
|
|
871 |
chchar = (aConvertedNumeral[0] + KLatinToDevanagariDigitsDelta);
|
|
872 |
}
|
|
873 |
break;
|
|
874 |
case EDigitTypeArabicIndic:
|
|
875 |
{
|
|
876 |
chchar = (aConvertedNumeral[0] + KLatinToArabicIndicDigitsDelta);
|
|
877 |
}
|
|
878 |
break;
|
|
879 |
case EDigitTypeEasternArabicIndic:
|
|
880 |
{
|
|
881 |
chchar = (aConvertedNumeral[0] + KLatinToEasternArabicIndicDigitsDelta);
|
|
882 |
}
|
|
883 |
}
|
|
884 |
aConvertedNumeral.Zero();
|
|
885 |
aConvertedNumeral.Append(chchar);
|
|
886 |
}
|
|
887 |
// End of file
|