javauis/lcdui_akn/lcdui/src/CMIDEdwin.cpp
branchRCL_3
changeset 23 e5618cc85d74
parent 21 4376525cdefb
child 24 6c158198356e
equal deleted inserted replaced
21:4376525cdefb 23:e5618cc85d74
   732 #ifdef RD_SCALABLE_UI_V2
   732 #ifdef RD_SCALABLE_UI_V2
   733     if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKey || aType == EEventKeyUp) && !IsReadOnly() &&
   733     if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKey || aType == EEventKeyUp) && !IsReadOnly() &&
   734 #else
   734 #else
   735     if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKeyUp) && !IsReadOnly() &&
   735     if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKeyUp) && !IsReadOnly() &&
   736 #endif // RD_SCALABLE_UI_V2
   736 #endif // RD_SCALABLE_UI_V2
   737             ((scanCode==EStdKeyNkpAsterisk) || (scanCode == EStdKeyMinus) || (scanCode==EStdKeyNkpMinus) || (scanCode == 0x2A) || (scanCode == 0x2D)))
   737             ((scanCode==EStdKeyNkpAsterisk) || (scanCode == EStdKeyMinus) || (scanCode==EStdKeyNkpMinus) || (scanCode == 0x2A) || (scanCode == 0x2D) ||
       
   738              (TChar(aKeyEvent.iCode) == TChar('-') && scanCode != EStdKeyMinus)))
   738     {
   739     {
   739         HandleMinusCharEventL(EEventTextUpdate);
   740         HandleMinusCharEventL(EEventTextUpdate);
   740         CEikEdwin::ReportEdwinEventL(EEventTextUpdate);
   741         CEikEdwin::ReportEdwinEventL(EEventTextUpdate);
   741         UpdateTextCapacityIndicatorValueL();
   742         UpdateTextCapacityIndicatorValueL();
   742         return EKeyWasConsumed;
   743         return EKeyWasConsumed;
   750 #endif // RD_SCALABLE_UI_V2
   751 #endif // RD_SCALABLE_UI_V2
   751             ((scanCode==EStdKeyMinus) || (scanCode==EStdKeyFullStop)))
   752             ((scanCode==EStdKeyMinus) || (scanCode==EStdKeyFullStop)))
   752     {
   753     {
   753         CPlainText* res = CEikEdwin::Text();
   754         CPlainText* res = CEikEdwin::Text();
   754         TInt textLength = CEikEdwin::TextLength();
   755         TInt textLength = CEikEdwin::TextLength();
   755         if (scanCode == EStdKeyMinus)
   756         if (scanCode == EStdKeyMinus && textLength < iMaxSize)
   756         {
   757         {
   757             res->InsertL(CEikEdwin::CursorPos(), KMinusChar);
   758             res->InsertL(CEikEdwin::CursorPos(), KMinusChar);
   758         }
   759         }
   759         else if (scanCode == EStdKeyFullStop)
   760         else if (scanCode == EStdKeyFullStop && textLength < iMaxSize)
   760         {
   761         {
   761             res->InsertL(CEikEdwin::CursorPos(), KFullStopChar);
   762             res->InsertL(CEikEdwin::CursorPos(), KFullStopChar);
   762         }
   763         }
   763 
   764 
   764         HandleTextChangedL(); // notify editor about the text changes
   765         HandleTextChangedL(); // notify editor about the text changes
   765         CEikEdwin::ReportEdwinEventL(EEventTextUpdate);
   766         CEikEdwin::ReportEdwinEventL(EEventTextUpdate);
       
   767         TInt cursorPos = CEikEdwin::CursorPos();
       
   768 
   766         if (CEikEdwin::TextLength() < iMaxSize)
   769         if (CEikEdwin::TextLength() < iMaxSize)
   767         {
   770         {
   768             CEikEdwin::SetCursorPosL(CEikEdwin::CursorPos() + 1, EFalse);
   771             CEikEdwin::SetCursorPosL(cursorPos + 1, EFalse);
       
   772         }
       
   773         else if (cursorPos == (iMaxSize - 1) && cursorPos == textLength && scanCode==EStdKeyFullStop)
       
   774         {
       
   775             CEikEdwin::SetCursorPosL(iMaxSize, EFalse);
   769         }
   776         }
   770     }
   777     }
   771     //Error tone playing case1:
   778     //Error tone playing case1:
   772     //Play error tone if TextBox/TextField is read-only or maximum length has been reached.
   779     //Play error tone if TextBox/TextField is read-only or maximum length has been reached.
   773     //Here is handling of keys 0...9 for full keyboard and itu-t, but NOT virtual keyboard.
   780     //Here is handling of keys 0...9 for full keyboard and itu-t, but NOT virtual keyboard.
   901             }
   908             }
   902 
   909 
   903             response = CEikEdwin::OfferKeyEventL(aKeyEvent,aType);
   910             response = CEikEdwin::OfferKeyEventL(aKeyEvent,aType);
   904             UpdateTextCapacityIndicatorValueL();
   911             UpdateTextCapacityIndicatorValueL();
   905         }
   912         }
       
   913         else
       
   914         {
       
   915             // If minus char was entered in full querty editor mode
       
   916             if (IsConstraintSet(MMIDTextField::EDecimal) &&
       
   917                     (aType == EEventKey) && !IsReadOnly() &&
       
   918                     (TChar(aKeyEvent.iCode) == TChar('-') && scanCode != EStdKeyMinus))
       
   919             {
       
   920                 CPlainText* res = CEikEdwin::Text();
       
   921 
       
   922                 if (res && TChar(aKeyEvent.iCode) == TChar('-') &&
       
   923                         TextLength() < iMaxSize)
       
   924                 {
       
   925                     res->InsertL(GetCaretPosition(), KMinusChar);
       
   926                     HandleTextChangedL(); // notify editor about the text changes
       
   927                     CEikEdwin::ReportEdwinEventL(EEventTextUpdate);
       
   928 
       
   929                     if (TextLength() < iMaxSize)
       
   930                     {
       
   931                         CEikEdwin::SetCursorPosL(GetCaretPosition() + 1, EFalse);
       
   932                     }
       
   933                 }
       
   934             }
       
   935 
       
   936         }
   906         return response;
   937         return response;
   907     }
   938     }
   908 }
   939 }
   909 
   940 
   910 void CMIDEdwin::FocusChanged(TDrawNow aDrawNow)
   941 void CMIDEdwin::FocusChanged(TDrawNow aDrawNow)
  1045             CleanupStack::PushL(res);
  1076             CleanupStack::PushL(res);
  1046 
  1077 
  1047             TInt illegalCharPos = -1;
  1078             TInt illegalCharPos = -1;
  1048             TPtr16 ptr = res->Des();
  1079             TPtr16 ptr = res->Des();
  1049             TInt minusPos = ptr.LocateReverse(TChar('-'));
  1080             TInt minusPos = ptr.LocateReverse(TChar('-'));
       
  1081             TInt endCursorPos = CEikEdwin::CursorPos();
  1050 
  1082 
  1051             // check if minus sign is inserted on incorrect place
  1083             // check if minus sign is inserted on incorrect place
  1052             // (not at the beginning)
  1084             // (not at the beginning)
  1053             if ((minusPos != KErrNotFound) && (minusPos != 0))
  1085             if ((minusPos != KErrNotFound) && (minusPos != 0))
  1054             {
  1086             {
  1092                 {
  1124                 {
  1093                     if (cursorPos == illegalCharPos)
  1125                     if (cursorPos == illegalCharPos)
  1094                     {
  1126                     {
  1095                         cursorPos--;
  1127                         cursorPos--;
  1096                     }
  1128                     }
  1097                     CEikEdwin::SetCursorPosL(cursorPos, EFalse);
  1129                     endCursorPos = cursorPos;
  1098                 }
  1130                 }
  1099             }
  1131             }
       
  1132             CEikEdwin::SetCursorPosL(endCursorPos, EFalse);
  1100             CleanupStack::Pop(res);
  1133             CleanupStack::Pop(res);
  1101             delete res;
  1134             delete res;
  1102         }
  1135         }
  1103         else if (((iConstraints &
  1136         else if (((iConstraints &
  1104                    MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr)||
  1137                    MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr)||