src/hbplugins/inputmethods/touchinput/hbinputprediction12keyhandler.cpp
changeset 23 e6ad4ef83b23
parent 21 4633027730f5
child 28 b7da29130b0e
equal deleted inserted replaced
21:4633027730f5 23:e6ad4ef83b23
    81 
    81 
    82     int buttonId = keyEvent->key();
    82     int buttonId = keyEvent->key();
    83 
    83 
    84     if (keyEvent->isAutoRepeat() && mLastKey == buttonId) {
    84     if (keyEvent->isAutoRepeat() && mLastKey == buttonId) {
    85         // mode switch should happen only when Qt::Key_Asterisk key is pressed in non-SCT
    85         // mode switch should happen only when Qt::Key_Asterisk key is pressed in non-SCT
    86         // keypad.			
    86         // keypad.          
    87         if (buttonId == HbInputButton::ButtonKeyCodeAsterisk &&
    87         if (buttonId == HbInputButton::ButtonKeyCodeAsterisk &&
    88             !mInputMethod->isSctModeActive()) {
    88             !mInputMethod->isSctModeActive()) {
    89             //Remove the "?" mark if present
    89             //Remove the "?" mark if present
    90             if (!mCanContinuePrediction) {
    90             if (!mCanContinuePrediction) {
    91                 chopQMarkAndUpdateEditor();
    91                 chopQMarkAndUpdateEditor();
    92             }	
    92             }   
    93             mInputMethod->switchMode(buttonId);
    93             mInputMethod->switchMode(buttonId);
    94             mLongPressHappened = true;
    94             mLongPressHappened = true;
    95         } else if (buttonId == HbInputButton::ButtonKeyCodeShift) {
    95         } else if (buttonId == HbInputButton::ButtonKeyCodeShift) {
    96             mInputMethod->switchMode(HbInputButton::ButtonKeyCodeShift);
    96             mInputMethod->switchMode(HbInputButton::ButtonKeyCodeShift);
    97             mLongPressHappened = true;
    97             mLongPressHappened = true;
   110             if (!mCanContinuePrediction) {
   110             if (!mCanContinuePrediction) {
   111                 deleteOneCharacter();
   111                 deleteOneCharacter();
   112                 mLongPressHappened = true;
   112                 mLongPressHappened = true;
   113             }
   113             }
   114             // commit the first mapped number character when long key press
   114             // commit the first mapped number character when long key press
   115             // of character key received in alphanumeric mode						
   115             // of character key received in alphanumeric mode                       
   116             if (buttonId != HbInputButton::ButtonKeyCodeDelete &&
   116             if (buttonId != HbInputButton::ButtonKeyCodeDelete &&
   117                 !mInputMethod->isSctModeActive()) {
   117                 !mInputMethod->isSctModeActive()) {
   118                 q->commitFirstMappedNumber(buttonId, mInputMethod->currentKeyboardType());
   118                 q->commitFirstMappedNumber(buttonId, mInputMethod->currentKeyboardType());
   119                 mLongPressHappened = true;
   119                 mLongPressHappened = true;
   120             }
   120             }
   154 
   154 
   155     // since button is released we can set buttonDown back to false.
   155     // since button is released we can set buttonDown back to false.
   156     mButtonDown = false;
   156     mButtonDown = false;
   157     int buttonId = keyEvent->key(); 
   157     int buttonId = keyEvent->key(); 
   158 
   158 
   159 	// short key press of character keys should not be handled when "?" is displayed
   159     // short key press of character keys should not be handled when "?" is displayed
   160     if (!mCanContinuePrediction && !mLongPressHappened &&
   160     if (!mCanContinuePrediction && !mLongPressHappened &&
   161 		buttonId >= Qt::Key_1 && buttonId <= Qt::Key_9) {
   161         buttonId >= Qt::Key_1 && buttonId <= Qt::Key_9) {
   162         return false;
   162         return false;
   163     }	
   163     }   
   164     // Sym key is handled in this class it self, so not passing it to 
   164     // Sym key is handled in this class it self, so not passing it to 
   165     // the base mode handlers.	
   165     // the base mode handlers.  
   166     if (buttonId == HbInputButton::ButtonKeyCodeSymbol ||
   166     if (buttonId == HbInputButton::ButtonKeyCodeSymbol ||
   167         buttonId == HbInputButton::ButtonKeyCodeAlphabet) {
   167         buttonId == HbInputButton::ButtonKeyCodeAlphabet) {
   168         //Remove the "?" mark if present
   168         //Remove the "?" mark if present
   169         chopQMarkAndUpdateEditor();
   169         chopQMarkAndUpdateEditor();
   170         mInputMethod->switchMode(buttonId);
   170         mInputMethod->switchMode(buttonId);
   174         - Should launch Candidate List if we can continue with prediction i.e. "?" is not displayed
   174         - Should launch Candidate List if we can continue with prediction i.e. "?" is not displayed
   175         - Should launch Spell Query Dialog if we cannot continue with prediction 
   175         - Should launch Spell Query Dialog if we cannot continue with prediction 
   176     - Behavior of Short Press of Asterisk Key when not in inline editing state 
   176     - Behavior of Short Press of Asterisk Key when not in inline editing state 
   177         - Should launch SCT
   177         - Should launch SCT
   178     - Behaviour of Short Press of Asterisk Key in SCT keypad
   178     - Behaviour of Short Press of Asterisk Key in SCT keypad
   179         - Should input the * character and should not change the keypad mode			
   179         - Should input the * character and should not change the keypad mode            
   180     */
   180     */
   181     else if (buttonId == HbInputButton::ButtonKeyCodeAsterisk &&
   181     else if (buttonId == HbInputButton::ButtonKeyCodeAsterisk &&
   182         !mInputMethod->isSctModeActive()) {
   182         !mInputMethod->isSctModeActive()) {
   183         if(!mCanContinuePrediction && (*mCandidates)[mBestGuessLocation].endsWith('?')) {			
   183         if(!mCanContinuePrediction && (*mCandidates)[mBestGuessLocation].endsWith('?')) {           
   184             //Remove the "?" mark
   184             //Remove the "?" mark
   185             (*mCandidates)[mBestGuessLocation].chop(1);
   185             (*mCandidates)[mBestGuessLocation].chop(1);
   186             updateEditor();
   186             updateEditor();
   187             q->launchSpellQueryDialog();
   187             q->launchSpellQueryDialog();
   188         } else {
   188         } else {
   199             if (mShiftKeyDoubleTap) {
   199             if (mShiftKeyDoubleTap) {
   200                 mTimer->stop();
   200                 mTimer->stop();
   201                 mShiftKeyDoubleTap = false;
   201                 mShiftKeyDoubleTap = false;
   202                 //mShowTail = false;
   202                 //mShowTail = false;
   203                 if (HbInputSettingProxy::instance()->globalInputLanguage()== mInputMethod->inputState().language()) {
   203                 if (HbInputSettingProxy::instance()->globalInputLanguage()== mInputMethod->inputState().language()) {
   204                     // in latin variants , double tap of shift key toggles the prediction status	
   204                     // in latin variants , double tap of shift key toggles the prediction status    
   205                     // revert back to the old case as this is a double tap 
   205                     // revert back to the old case as this is a double tap 
   206                     // (the case was changed on the single tap)
   206                     // (the case was changed on the single tap)
   207                     updateTextCase();
   207                     updateTextCase();
   208                     q->togglePrediction();
   208                     q->togglePrediction();
   209                 } else {
   209                 } else {
   222                 }
   222                 }
   223             }
   223             }
   224         }
   224         }
   225         return true;
   225         return true;
   226     }
   226     }
   227 	// ButtonKeyCodeSettings should not be propagated to the engine
   227     // ButtonKeyCodeSettings should not be propagated to the engine
   228     if(buttonId == HbInputButton::ButtonKeyCodeSettings) {
   228     if(buttonId == HbInputButton::ButtonKeyCodeSettings) {
   229         return true;
   229         return true;
   230     }
   230     }
   231     if (buttonId != HbInputButton::ButtonKeyCodeDelete &&
   231     if (buttonId != HbInputButton::ButtonKeyCodeDelete &&
   232         buttonId != HbInputButton::ButtonKeyCodeEnter &&
   232         buttonId != HbInputButton::ButtonKeyCodeEnter &&
   236     }
   236     }
   237 
   237 
   238     // text input happens on button release
   238     // text input happens on button release
   239     if (q->HbInputPredictionHandler::filterEvent(keyEvent)) {
   239     if (q->HbInputPredictionHandler::filterEvent(keyEvent)) {
   240         return true;
   240         return true;
   241     }	
   241     }   
   242     return false;
   242     return false;
   243 }
   243 }
   244 
   244 
   245 
   245 
   246 void HbInputPrediction12KeyHandlerPrivate::cancelButtonPress()
   246 void HbInputPrediction12KeyHandlerPrivate::cancelButtonPress()
   283     //any meaningful word for the input sequence.
   283     //any meaningful word for the input sequence.
   284     if(!d->mCanContinuePrediction) {
   284     if(!d->mCanContinuePrediction) {
   285         int eventKey = event->key();
   285         int eventKey = event->key();
   286         switch(eventKey) {
   286         switch(eventKey) {
   287         case Qt::Key_0:
   287         case Qt::Key_0:
       
   288         case HbInputButton::ButtonKeyCodeSettings:
   288         case HbInputButton::ButtonKeyCodeSpace: {
   289         case HbInputButton::ButtonKeyCodeSpace: {
   289             if(d->mCandidates->size() && focusObject) {
   290             if(d->mCandidates->size() && focusObject) {
   290                 //Remove the "?" mark
   291                 //Remove the "?" mark
   291                 (*d->mCandidates)[d->mBestGuessLocation].chop(1);
   292                 (*d->mCandidates)[d->mBestGuessLocation].chop(1);
   292                 d->updateEditor();
   293                 d->updateEditor();