javauis/lcdui_akn/lcdui/src/CMIDTextEditorEdwin.cpp
branchRCL_3
changeset 71 d5e927d5853b
parent 66 2455ef1f5bbc
child 83 26b2b12093af
equal deleted inserted replaced
66:2455ef1f5bbc 71:d5e927d5853b
   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         // Consume down and up type of keyevents
   159         // Consume down and up type of keyevents
   160         if ((response == EKeyWasConsumed) || 
   160         if ((response == EKeyWasConsumed) ||
   161                 (aType != EEventKey && aKeyEvent.iScanCode != 
   161                 (aType != EEventKey && aKeyEvent.iScanCode !=
   162                 EStdKeyApplication0))
   162                  EStdKeyApplication0))
   163         {
   163         {
   164             response = EKeyWasConsumed;
   164             response = EKeyWasConsumed;
   165         }
   165         }
   166         else
   166         else
   167         {
   167         {
   176             HBufC* oldContent = GetTextInHBufL();
   176             HBufC* oldContent = GetTextInHBufL();
   177 
   177 
   178             CleanupStack::PushL(oldContent);
   178             CleanupStack::PushL(oldContent);
   179 
   179 
   180             response = CEikEdwin::OfferKeyEventL(aKeyEvent, aType);
   180             response = CEikEdwin::OfferKeyEventL(aKeyEvent, aType);
   181             
   181 
   182             if (response == EKeyWasConsumed) {
   182             if (response == EKeyWasConsumed)
       
   183             {
   183                 // Validate new content and undo if not valid.
   184                 // Validate new content and undo if not valid.
   184                 if (!iEdwinUtils.ConstraintsValidForText(
   185                 if (!iEdwinUtils.ConstraintsValidForText(
   185                             Read(), iConstraints, EFalse))
   186                             Read(), iConstraints, EFalse))
   186                 {
   187                 {
   187                     CEikEdwin::SetTextL(oldContent);
   188                     CEikEdwin::SetTextL(oldContent);
   190                     // Restore cursor's original position.
   191                     // Restore cursor's original position.
   191                     SetCursorPosL(iCursorPosForAction, EFalse);
   192                     SetCursorPosL(iCursorPosForAction, EFalse);
   192                 }
   193                 }
   193             }
   194             }
   194             else
   195             else
   195             { 
   196             {
   196                 // Consuming the up/down arrows, because edwin does not 
   197                 // Consuming the up/down arrows, because edwin does not
   197                 // consume them if at first/last line. 
   198                 // consume them when using predictive text
   198                 if ((aType == EEventKey) &&
   199                 if (((aKeyEvent.iCode == EKeyUpArrow) ||
   199                         (((aKeyEvent.iCode == EKeyUpArrow) ||
   200                         (aKeyEvent.iCode == EKeyDownArrow)) ||
   200                           (aKeyEvent.iCode == EKeyDownArrow)) ||
   201                         ((aKeyEvent.iScanCode == EStdKeyUpArrow) ||
   201                          ((aKeyEvent.iScanCode == EStdKeyUpArrow) ||
   202                          (aKeyEvent.iScanCode == EStdKeyDownArrow)))
   202                           (aKeyEvent.iScanCode == EStdKeyDownArrow))))
       
   203                 {
   203                 {
   204                     response = EKeyWasConsumed;
   204                     response = EKeyWasConsumed;
   205                 }
   205                 }
   206             }
   206             }
   207             CleanupStack::PopAndDestroy(oldContent);
   207             CleanupStack::PopAndDestroy(oldContent);