javauis/lcdui_akn/lcdui/src/CMIDTextFieldItem.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
   324 
   324 
   325 }
   325 }
   326 
   326 
   327 void CMIDTextFieldItem::FocusChanged(TDrawNow aDrawNow)
   327 void CMIDTextFieldItem::FocusChanged(TDrawNow aDrawNow)
   328 {
   328 {
       
   329     TBool cursorVisibility = EFalse;
   329     if (IsFocused())
   330     if (IsFocused())
   330     {
   331     {
   331         // Setting focus to iTextField changes the cursor visibility. This might cause
   332         // Setting focus to iTextField changes the cursor visibility. This might cause
   332         // a cursor flashing on the screen, if the focus is set to a TF that is not in the
   333         // a cursor flashing on the screen, if the focus is set to a TF that is not in the
   333         // visible form area currently when a form is switched from background
   334         // visible form area currently when a form is switched from background
   334         // to foreground. To prevent this EAvkonDisableCursor is set temporarily.
   335         // to foreground. To prevent this EAvkonDisableCursor is set temporarily.
   335         iTextField->AddFlagToUserFlags(CEikEdwin::EAvkonDisableCursor);
   336         iTextField->AddFlagToUserFlags(CEikEdwin::EAvkonDisableCursor);
   336         iTextField->SetFocus(ETrue);
   337         iTextField->SetFocus(ETrue);
   337         iTextField->RemoveFlagFromUserFlags(CEikEdwin::EAvkonDisableCursor);
   338         iTextField->RemoveFlagFromUserFlags(CEikEdwin::EAvkonDisableCursor);
   338         SetCursorVisibility(IsVisible());
   339         cursorVisibility = IsVisible();
   339     }
   340     }
   340     else
   341     else
   341     {
   342     {
   342         iTextField->SetFocus(EFalse);
   343         iTextField->SetFocus(EFalse);
       
   344         cursorVisibility = EFalse;
   343     }
   345     }
   344 
   346 
   345     CMIDControlItem::FocusChanged(aDrawNow);
   347     CMIDControlItem::FocusChanged(aDrawNow);
   346     // DoLayout and change text color when focused
   348     // DoLayout and change text color when focused
   347     SizeChanged();
   349     SizeChanged();
   348     TRAP_IGNORE(UpdateTextColorsL());
   350     TRAP_IGNORE(UpdateTextColorsL());
       
   351 
       
   352     SetCursorVisibility(cursorVisibility);
   349 }
   353 }
   350 
   354 
   351 void CMIDTextFieldItem::HandleCurrentL(TBool aCurrent)
   355 void CMIDTextFieldItem::HandleCurrentL(TBool aCurrent)
   352 {
   356 {
   353     // set initial input modes when TextField becomes the focused item
   357     // set initial input modes when TextField becomes the focused item
   384 #ifdef RD_SCALABLE_UI_V2
   388 #ifdef RD_SCALABLE_UI_V2
   385 void CMIDTextFieldItem::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   389 void CMIDTextFieldItem::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   386 {
   390 {
   387     if (AknLayoutUtils::PenEnabled())
   391     if (AknLayoutUtils::PenEnabled())
   388     {
   392     {
   389         if (!iForm->PhysicsScrolling())
   393         if (!iForm->PhysicsScrolling() && !iTextField->IsReadOnly())
   390         {
   394         {
   391             SetCursorVisibility(ETrue);
   395             SetCursorVisibility(ETrue);
   392         }
   396         }
   393 
   397 
   394         //update focus
   398         //update focus
   665     if (IsFocused())
   669     if (IsFocused())
   666     {
   670     {
   667         TCursor::TVisibility textCursor =
   671         TCursor::TVisibility textCursor =
   668             aVisible ? TCursor::EFCursorFlashing : TCursor::EFCursorInvisible;
   672             aVisible ? TCursor::EFCursorFlashing : TCursor::EFCursorInvisible;
   669 
   673 
       
   674         if (iTextField->IsReadOnly())
       
   675         {
       
   676             textCursor = TCursor::EFCursorInvisible;
       
   677         }
       
   678 
   670         // lineCursor is not used in TextField, so it is set to TCursor::EFCursorInvisible always
   679         // lineCursor is not used in TextField, so it is set to TCursor::EFCursorInvisible always
   671         TRAP_IGNORE(iTextField->TextView()->SetCursorVisibilityL(TCursor::EFCursorInvisible,
   680         TRAP_IGNORE(iTextField->TextView()->SetCursorVisibilityL(TCursor::EFCursorInvisible,
   672                     textCursor));
   681                     textCursor));
   673     }
   682     }
   674 }
   683 }
   675 
   684 
   676 void CMIDTextFieldItem::UpdateTextColorsL()
   685 void CMIDTextFieldItem::UpdateTextColorsL()
   677 {
   686 {
   678     if (iTextField)
   687     if (iTextField && !iTextField->IsReadOnly())
   679     {
   688     {
   680         // Set color for content text according to item highlight
   689         // Set color for content text according to item highlight
   681         // (logical color constants are defined in lcdui.h)
   690         // (logical color constants are defined in lcdui.h)
   682         if (iHighlighted)
   691         if (iHighlighted)
   683         {
   692         {