javauis/lcdui_akn/lcdui/src/CMIDTextEditorEdwin.cpp
branchRCL_3
changeset 23 e5618cc85d74
parent 21 4376525cdefb
equal deleted inserted replaced
21:4376525cdefb 23:e5618cc85d74
   154 
   154 
   155         // Try handling special characters.
   155         // Try handling special characters.
   156         response = HandleSpecialKeyEventsL(aKeyEvent, aType);
   156         response = HandleSpecialKeyEventsL(aKeyEvent, aType);
   157 
   157 
   158         // Not handled, try with CEikEdwin
   158         // Not handled, try with CEikEdwin
   159         if (response == EKeyWasNotConsumed)
   159         // Consume down and up type of keyevents
       
   160         if ((response == EKeyWasConsumed) || 
       
   161                 (aType != EEventKey && aKeyEvent.iScanCode != 
       
   162                 EStdKeyApplication0))
       
   163         {
       
   164             response = EKeyWasConsumed;
       
   165         }
       
   166         else
   160         {
   167         {
   161             // Old text is needed if the new content is not valid for the
   168             // Old text is needed if the new content is not valid for the
   162             // given set of constraints. This validation is made because
   169             // given set of constraints. This validation is made because
   163             // CEikEdwin and FEP seem to input text that is not always
   170             // CEikEdwin and FEP seem to input text that is not always
   164             // valid for the given Java-specific constraints. No very
   171             // valid for the given Java-specific constraints. No very
   169             HBufC* oldContent = GetTextInHBufL();
   176             HBufC* oldContent = GetTextInHBufL();
   170 
   177 
   171             CleanupStack::PushL(oldContent);
   178             CleanupStack::PushL(oldContent);
   172 
   179 
   173             response = CEikEdwin::OfferKeyEventL(aKeyEvent, aType);
   180             response = CEikEdwin::OfferKeyEventL(aKeyEvent, aType);
   174 
   181             
   175             // Validate new content and undo if not valid.
   182             if (response == EKeyWasConsumed) {
   176             if (!iEdwinUtils.ConstraintsValidForText(
   183                 // Validate new content and undo if not valid.
   177                         Read(), iConstraints, EFalse))
   184                 if (!iEdwinUtils.ConstraintsValidForText(
   178             {
   185                             Read(), iConstraints, EFalse))
   179                 CEikEdwin::SetTextL(oldContent);
   186                 {
   180                 // Notify about text change.
   187                     CEikEdwin::SetTextL(oldContent);
   181                 HandleTextChangedL();
   188                     // Notify about text change.
   182                 // Restore cursor's original position.
   189                     HandleTextChangedL();
   183                 SetCursorPosL(iCursorPosForAction, EFalse);
   190                     // Restore cursor's original position.
       
   191                     SetCursorPosL(iCursorPosForAction, EFalse);
       
   192                 }
       
   193             }
       
   194             else
       
   195             { 
       
   196                 // Consuming the up/down arrows, because edwin does not 
       
   197                 // consume them if at first/last line. 
       
   198                 if ((aType == EEventKey) &&
       
   199                         (((aKeyEvent.iCode == EKeyUpArrow) ||
       
   200                           (aKeyEvent.iCode == EKeyDownArrow)) ||
       
   201                          ((aKeyEvent.iScanCode == EStdKeyUpArrow) ||
       
   202                           (aKeyEvent.iScanCode == EStdKeyDownArrow))))
       
   203                 {
       
   204                     response = EKeyWasConsumed;
       
   205                 }
   184             }
   206             }
   185             CleanupStack::PopAndDestroy(oldContent);
   207             CleanupStack::PopAndDestroy(oldContent);
   186         }
   208         }
   187 
   209 
   188         // Update current selection.
   210         // Update current selection.
   546 // (other items were commented in the header file)
   568 // (other items were commented in the header file)
   547 // ---------------------------------------------------------------------------
   569 // ---------------------------------------------------------------------------
   548 //
   570 //
   549 void CMIDTextEditorEdwin::HandleResourceChange(TInt aType)
   571 void CMIDTextEditorEdwin::HandleResourceChange(TInt aType)
   550 {
   572 {
   551     CCoeControl::HandleResourceChange(aType);
   573     CEikEdwin::HandleResourceChange(aType);
   552     // Notification about language change
   574     // Notification about language change
   553     if (aType == KEikInputLanguageChange)
   575     if (aType == KEikInputLanguageChange)
   554     {
   576     {
   555         if (iObserver)
   577         if (iObserver)
   556         {
   578         {