59 return false; |
59 return false; |
60 } |
60 } |
61 |
61 |
62 int index = mNumChr; |
62 int index = mNumChr; |
63 do { |
63 do { |
|
64 int currCharIndex = 0; |
|
65 mCurrentChar = 0; |
64 //This condition is to avoid get the characters mapped to Asterisk |
66 //This condition is to avoid get the characters mapped to Asterisk |
65 //Especially for Thai language we have mapped character to Asterisk |
67 //Especially for Thai language we have mapped character to Asterisk |
66 if (buttonId != HbInputButton::ButtonKeyCodeAsterisk || |
68 if (buttonId != HbInputButton::ButtonKeyCodeAsterisk || |
67 mInputMethod->currentKeyboardType() == HbKeyboardSctPortrait) { |
69 mInputMethod->currentKeyboardType() == HbKeyboardSctPortrait) { |
|
70 currCharIndex = mNumChr ; |
68 mCurrentChar = q->getNthCharacterInKey(mNumChr, buttonId, type); |
71 mCurrentChar = q->getNthCharacterInKey(mNumChr, buttonId, type); |
69 } |
72 } |
70 |
73 |
71 if (mCurrentChar != 0) { |
74 if (mCurrentChar != 0) { |
72 if (focusObject->characterAllowedInEditor(mCurrentChar)) { |
75 if (focusObject->characterAllowedInEditor(mCurrentChar)) { |
73 QString str; |
76 //If the keypad is SCT or button has only one character that is allowed to editor, |
74 str += mCurrentChar; |
77 //we can commit the character immidiately |
75 |
78 if (mInputMethod->currentKeyboardType() == HbKeyboardSctPortrait || currCharIndex == mNumChr) { |
76 //If the keypad is SCT, we can commit the character immidiately |
79 _q_timeout(); |
77 if (mInputMethod->currentKeyboardType() == HbKeyboardSctPortrait) { |
|
78 focusObject->filterAndCommitCharacter(mCurrentChar); |
|
79 mCurrentChar = 0; |
|
80 } else { |
80 } else { |
|
81 QString str; |
|
82 str += mCurrentChar; |
81 QList<QInputMethodEvent::Attribute> list; |
83 QList<QInputMethodEvent::Attribute> list; |
82 QInputMethodEvent event(str, list); |
84 QInputMethodEvent event(str, list); |
83 focusObject->sendEvent(event); |
85 focusObject->sendEvent(event); |
84 } |
86 } |
85 return true; |
87 return true; |
104 if (keyEvent->isAutoRepeat() && mDownKey == buttonId) { |
106 if (keyEvent->isAutoRepeat() && mDownKey == buttonId) { |
105 mTimer->stop(); |
107 mTimer->stop(); |
106 if (mDownKey == HbInputButton::ButtonKeyCodeShift) { |
108 if (mDownKey == HbInputButton::ButtonKeyCodeShift) { |
107 mLongPressHappened = true; |
109 mLongPressHappened = true; |
108 mInputMethod->switchMode(HbInputButton::ButtonKeyCodeShift); |
110 mInputMethod->switchMode(HbInputButton::ButtonKeyCodeShift); |
109 } else if (mDownKey == HbInputButton::ButtonKeyCodeSymbol || |
111 } else if (mDownKey == HbInputButton::ButtonKeyCodeSymbol) { |
110 (mDownKey == HbInputButton::ButtonKeyCodeAsterisk && |
112 // launch the smiley popup when long press of Sym key is received |
111 mInputMethod->currentKeyboardType() != HbKeyboardSctPortrait)) { |
|
112 mLongPressHappened = true; |
113 mLongPressHappened = true; |
113 mInputMethod->selectSpecialCharacterTableMode(); |
114 mInputMethod->selectSpecialCharacterTableMode(); |
|
115 } else if (mDownKey == HbInputButton::ButtonKeyCodeAsterisk && |
|
116 // launch the SCT keypad when long press of Asterisk key is |
|
117 // received in non-SCT mode |
|
118 !mInputMethod->isSctModeActive()) { |
|
119 mLongPressHappened = true; |
|
120 mInputMethod->switchMode(mDownKey); |
114 } else if (mDownKey != HbInputButton::ButtonKeyCodeDelete && |
121 } else if (mDownKey != HbInputButton::ButtonKeyCodeDelete && |
115 mInputMethod->currentKeyboardType() != HbKeyboardSctPortrait) { |
122 mInputMethod->currentKeyboardType() != HbKeyboardSctPortrait) { |
116 mLongPressHappened = true; |
123 mLongPressHappened = true; |
117 q->commitFirstMappedNumber(mDownKey, mInputMethod->currentKeyboardType()); |
124 q->commitFirstMappedNumber(mDownKey, mInputMethod->currentKeyboardType()); |
118 } |
125 } |
159 Handles the key release events from the VKB. Launches the SCT with key release event of |
166 Handles the key release events from the VKB. Launches the SCT with key release event of |
160 asterisk. |
167 asterisk. |
161 */ |
168 */ |
162 bool HbInputBasic12KeyHandlerPrivate::buttonReleased(const QKeyEvent *keyEvent) |
169 bool HbInputBasic12KeyHandlerPrivate::buttonReleased(const QKeyEvent *keyEvent) |
163 { |
170 { |
164 HbInputVkbWidget::HbFlickDirection flickDir = static_cast<HbVirtual12Key*>(mInputMethod)->flickDirection(); |
171 if (mInputMethod) { |
165 if (mInputMethod && flickDir!=HbInputVkbWidget::HbFlickDirectionDown) { |
|
166 Q_Q(HbInputBasic12KeyHandler); |
172 Q_Q(HbInputBasic12KeyHandler); |
167 int buttonId = keyEvent->key(); |
173 int buttonId = keyEvent->key(); |
168 HbInputFocusObject *focusObject = mInputMethod->focusObject(); |
174 HbInputFocusObject *focusObject = mInputMethod->focusObject(); |
169 if (!focusObject || !mDownKey) { |
175 if (!focusObject || !mDownKey) { |
170 return false; |
176 return false; |
171 } |
177 } |
172 mDownKey = 0; |
178 mDownKey = 0; |
173 if (mLongPressHappened){ |
179 if ( mLongPressHappened ){ |
174 mLongPressHappened = false; |
180 mLongPressHappened = false; |
175 return false; |
181 return false; |
176 } |
182 } |
177 |
183 |
178 if (mTimer->isActive() && mLastKey != buttonId) { |
184 if(mTimer->isActive() && mLastKey != buttonId) { |
179 mNumChr = 0; |
185 mNumChr = 0; |
180 |
186 |
181 // For QLineEdit it works fine. For HbLineEdit, need to set the state |
187 // For QLineEdit it works fine. For HbLineEdit, need to set the state |
182 // to lower by calling activateState(). |
188 // to lower by calling activateState(). |
183 // This is needed for the scenario - When automatic text case is true |
189 // This is needed for the scenario - When automatic text case is true |
190 mInputMethod->updateState(); |
196 mInputMethod->updateState(); |
191 } |
197 } |
192 refreshAutoCompleter(); |
198 refreshAutoCompleter(); |
193 } |
199 } |
194 |
200 |
195 if (buttonId == HbInputButton::ButtonKeyCodeEnter) { |
201 if (buttonId == HbInputButton::ButtonKeyCodeShift) { |
196 mInputMethod->closeKeypad(); |
|
197 mLastKey = buttonId; |
|
198 return true; |
|
199 } else if (buttonId == HbInputButton::ButtonKeyCodeShift) { |
|
200 // single tap of shift key toggles prediction status in case insensitive languages |
202 // single tap of shift key toggles prediction status in case insensitive languages |
201 // The Editor should not be Web or URL which allows only Latin Alphabet |
203 // The Editor should not be Web or URL which allows only Latin Alphabet |
202 if (!HbInputSettingProxy::instance()->globalInputLanguage().isCaseSensitiveLanguage() && |
204 if (!HbInputSettingProxy::instance()->globalInputLanguage().isCaseSensitiveLanguage() && |
203 ((HbEditorConstraintLatinAlphabetOnly | HbEditorConstraintAutoCompletingField)!=focusObject->editorInterface().inputConstraints()) && |
205 ((HbEditorConstraintLatinAlphabetOnly | HbEditorConstraintAutoCompletingField)!=focusObject->editorInterface().inputConstraints()) && |
204 // when the language does not support prediction in that case we should not update the state and prediction |
206 // when the language does not support prediction in that case we should not update the state and prediction |
205 HbPredictionFactory::instance()->predictionEngineForLanguage(mInputMethod->inputState().language())) { |
207 HbPredictionFactory::instance()->predictionEngineForLanguage(mInputMethod->inputState().language())) { |
206 HbInputSettingProxy::instance()->togglePrediction(); |
208 HbInputSettingProxy::instance()->togglePrediction(); |
216 // in latin variants , double tap of shift key toggles the prediction status |
218 // in latin variants , double tap of shift key toggles the prediction status |
217 // revert back to the old case as this is a double tap |
219 // revert back to the old case as this is a double tap |
218 // (the case was changed on the single tap) |
220 // (the case was changed on the single tap) |
219 updateTextCase(); |
221 updateTextCase(); |
220 // when the language does not support prediction in that case we should not update the state and prediction |
222 // when the language does not support prediction in that case we should not update the state and prediction |
221 if(HbPredictionFactory::instance()->predictionEngineForLanguage(mInputMethod->inputState().language())) { |
223 if(HbPredictionFactory::instance()->predictionEngineForLanguage(mInputMethod->inputState().language()) && |
|
224 mInputMethod->focusObject()->editorInterface().isPredictionAllowed()) { |
222 q->togglePrediction(); |
225 q->togglePrediction(); |
223 } |
226 } |
224 } else { |
227 } else { |
225 // if the global language is different from the input mode language, we should |
228 // if the global language is different from the input mode language, we should |
226 // go back to the root state |
229 // go back to the root state |
252 |
255 |
253 // it was a long press on sct swith button. so just return form here. |
256 // it was a long press on sct swith button. so just return form here. |
254 if (!mTimer->isActive() && buttonId == HbInputButton::ButtonKeyCodeSymbol) { |
257 if (!mTimer->isActive() && buttonId == HbInputButton::ButtonKeyCodeSymbol) { |
255 return true; |
258 return true; |
256 } |
259 } |
257 if (buttonId == HbInputButton::ButtonKeyCodeAsterisk || buttonId == HbInputButton::ButtonKeyCodeSymbol || |
260 // switch the keypad mode when the short key press of Asterisk key in non-SCT mode |
|
261 // or SYM button or Alphabet button is received |
|
262 if ((buttonId == HbInputButton::ButtonKeyCodeAsterisk && |
|
263 !mInputMethod->isSctModeActive()) || buttonId == HbInputButton::ButtonKeyCodeSymbol || |
258 buttonId == HbInputButton::ButtonKeyCodeAlphabet) { |
264 buttonId == HbInputButton::ButtonKeyCodeAlphabet) { |
259 //Same asterisk key is used for launching candidate list (long key press) |
|
260 //and also for SCT. So, do not launch SCT if candidate list is already launched. |
|
261 mInputMethod->switchMode(buttonId); |
265 mInputMethod->switchMode(buttonId); |
262 return true; |
266 return true; |
263 } |
267 } |
264 } |
268 } |
265 return false; |
269 return false; |