javauis/lcdui_akn/lcdui/src/CMIDTextBoxQueryDialog.cpp
branchRCL_3
changeset 60 6c158198356e
parent 59 e5618cc85d74
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
   453 }
   453 }
   454 
   454 
   455 void CMIDTextBoxQueryDialog::FocusChanged(TDrawNow aDrawNow)
   455 void CMIDTextBoxQueryDialog::FocusChanged(TDrawNow aDrawNow)
   456 {
   456 {
   457     CAknTextQueryDialog::FocusChanged(aDrawNow);
   457     CAknTextQueryDialog::FocusChanged(aDrawNow);
   458     TRAP_IGNORE(UpdateScrollBarPositionL());
       
   459 }
   458 }
   460 //
   459 //
   461 // We do not want to become visible if we are not showing
   460 // We do not want to become visible if we are not showing
   462 //
   461 //
   463 void CMIDTextBoxQueryDialog::MakeVisible(TBool aVisible)
   462 void CMIDTextBoxQueryDialog::MakeVisible(TBool aVisible)
   687 
   686 
   688         if (Size() < iMaxSize)
   687         if (Size() < iMaxSize)
   689         {
   688         {
   690             SetCursorPositionL(cursorPos + 1);
   689             SetCursorPositionL(cursorPos + 1);
   691         }
   690         }
   692         else if (cursorPos == (iMaxSize - 1) && cursorPos == textLength && scanCode==EStdKeyFullStop)
   691         else if (cursorPos == (iMaxSize - 1) && cursorPos == textLength &&
       
   692                  (scanCode == EStdKeyFullStop || scanCode == EStdKeyMinus))
   693         {
   693         {
   694             SetCursorPositionL(iMaxSize);
   694             SetCursorPositionL(iMaxSize);
   695         }
   695         }
   696 
   696 
   697         HandleTextUpdateL(MEikEdwinObserver::EEventTextUpdate);
   697         HandleTextUpdateL(MEikEdwinObserver::EEventTextUpdate);
   766     TBool isFocused = IsFocused();
   766     TBool isFocused = IsFocused();
   767 
   767 
   768     // If there is no focus textbox should not consume keys
   768     // If there is no focus textbox should not consume keys
   769     if (isFocused)
   769     if (isFocused)
   770     {
   770     {
   771         //Error tone playing case2:
   771         // Error tone playing case2:
   772         //Play error tone if TextBox/TextField is read-only or maximum length has been reached.
   772         // Play error tone if TextBox/TextField is read-only or maximum length has been reached.
   773         //Here is handling of full keyboard keys(NOT 0...9) and all virtual keyboard keys.
   773         // Here is handling of full keyboard keys(NOT 0...9) and all virtual keyboard keys
   774         //(Note: Virtual keyboard sends only EEventKey type events, not up or down events)
   774         // (camera and menu key not included).
   775         //(Note: Error tone is played when there is no text to be replaced i.e. no text has been painted)
   775         // (Note: Virtual keyboard sends only EEventKey type events, not up or down events)
   776         if (!iEdwinUtils->IsNavigationKey(aKeyEvent) && !iEdwinUtils->IsHotKeyL(aKeyEvent, iCoeEnv) && !aKeyEvent.iCode == EKeyYes &&
   776         // (Note: Error tone is played when there is no text to be replaced i.e. no text has been painted)
   777                 (!iKeyEventsPending || (scanCode < KKeyQwerty0  || scanCode > KKeyQwerty9)))
   777         if (!iEdwinUtils->IsNavigationKey(aKeyEvent) && !iEdwinUtils->IsHotKeyL(aKeyEvent, iCoeEnv) && aKeyEvent.iCode != EKeyYes &&
       
   778                 (!iKeyEventsPending || (scanCode < KKeyQwerty0  || scanCode > KKeyQwerty9)) &&
       
   779                 (aKeyEvent.iCode != EKeyApplication0 && scanCode != EStdKeyApplication0 &&
       
   780                  aKeyEvent.iCode != EKeyApplication19 && scanCode != EStdKeyApplication19))
   778         {
   781         {
   779             if (iEditor->IsReadOnly() || (Size() >= iMaxSize && aKeyEvent.iCode != EKeyBackspace))
   782             if (iEditor->IsReadOnly() || (Size() >= iMaxSize && aKeyEvent.iCode != EKeyBackspace))
   780             {
   783             {
   781                 //SelectionLength() > 0 if text has been selected/painted
   784                 //SelectionLength() > 0 if text has been selected/painted
   782                 if (iEditor->SelectionLength() == 0)
   785                 if (iEditor->SelectionLength() == 0)
   833                     CPlainText* res = iEditor->Text();
   836                     CPlainText* res = iEditor->Text();
   834 
   837 
   835                     if (res && TChar(aKeyEvent.iCode) == TChar('-') &&
   838                     if (res && TChar(aKeyEvent.iCode) == TChar('-') &&
   836                             Size() < iMaxSize)
   839                             Size() < iMaxSize)
   837                     {
   840                     {
       
   841                         TInt textLength = Size();
   838                         res->InsertL(GetCaretPosition(), KMinusChar);
   842                         res->InsertL(GetCaretPosition(), KMinusChar);
   839                         // notify editor about the text changes
   843                         // notify editor about the text changes
   840                         iEditor->HandleTextChangedL();
   844                         iEditor->HandleTextChangedL();
       
   845                         TInt cursorPos = GetCaretPosition();
   841 
   846 
   842                         if (Size() < iMaxSize)
   847                         if (Size() < iMaxSize)
   843                         {
   848                         {
   844                             SetCursorPositionL(GetCaretPosition() + 1);
   849                             SetCursorPositionL(GetCaretPosition() + 1);
   845                         }
   850                         }
   846 
   851                         else if (cursorPos == (iMaxSize - 1) && cursorPos == textLength)
       
   852 
       
   853                         {
       
   854                             SetCursorPositionL(iMaxSize);
       
   855                         }
   847                         //Prevent changes that would result in an illegal string
   856                         //Prevent changes that would result in an illegal string
   848                         HandleTextUpdateL(MEikEdwinObserver::EEventTextUpdate);
   857                         HandleTextUpdateL(MEikEdwinObserver::EEventTextUpdate);
   849                     }
   858                     }
   850                 }
   859                 }
   851 
   860 
  1067 
  1076 
  1068             UpdateInitialInputModes();
  1077             UpdateInitialInputModes();
  1069         }
  1078         }
  1070         else
  1079         else
  1071         {
  1080         {
       
  1081             // avoid po-pup dialog box blinking
       
  1082             MakeVisible(EFalse);
       
  1083 
  1072             ExitSleepingDialog();
  1084             ExitSleepingDialog();
  1073 #ifdef RD_SCALABLE_UI_V2
  1085 #ifdef RD_SCALABLE_UI_V2
  1074             SetPointerCapture(EFalse);
  1086             SetPointerCapture(EFalse);
  1075 #endif
  1087 #endif
  1076 
  1088 
  1280         }
  1292         }
  1281     }
  1293     }
  1282 
  1294 
  1283     iThisMultitapKey = 0;   // reset key counter
  1295     iThisMultitapKey = 0;   // reset key counter
  1284     iLastMultitapKey = 0;
  1296     iLastMultitapKey = 0;
       
  1297     
       
  1298     if(iEditor->ScrollBarFrame())
       
  1299     {
       
  1300         iEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff);
       
  1301     }
  1285 }
  1302 }
  1286 
  1303 
  1287 TBool CMIDTextBoxQueryDialog::Showing()
  1304 TBool CMIDTextBoxQueryDialog::Showing()
  1288 {
  1305 {
  1289     return iShowing;
  1306     return iShowing;
  1548  * screen dynamic resolution change.
  1565  * screen dynamic resolution change.
  1549  */
  1566  */
  1550 void CMIDTextBoxQueryDialog::HandleResourceChange(TInt aType)
  1567 void CMIDTextBoxQueryDialog::HandleResourceChange(TInt aType)
  1551 {
  1568 {
  1552     CAknTextQueryDialog::HandleResourceChange(aType);
  1569     CAknTextQueryDialog::HandleResourceChange(aType);
  1553     if (aType == KEikDynamicLayoutVariantSwitch ||
  1570     TRAP_IGNORE(UpdateScrollBarPositionL());
  1554             aType == KEikColorResourceChange || aType == KAknsMessageSkinChange ||
       
  1555             aType == KUidValueCoeColorSchemeChangeEvent)
       
  1556     {
       
  1557         TRAP_IGNORE(UpdateScrollBarPositionL());
       
  1558     }
       
  1559 }
  1571 }
  1560 
  1572 
  1561 /* UpdateScrollBarPositionL
  1573 /* UpdateScrollBarPositionL
  1562  *
  1574  *
  1563  * This method is called for placing scrollbar to correct place in edwin
  1575  * This method is called for placing scrollbar to correct place in edwin
  1564  */
  1576  */
  1565 void CMIDTextBoxQueryDialog::UpdateScrollBarPositionL()
  1577 void CMIDTextBoxQueryDialog::UpdateScrollBarPositionL()
  1566 {
  1578 {
  1567     if(iEditor && iEditor->TextLayout())
  1579     if (iEditor && iEditor->TextLayout())
  1568     {
  1580     {
  1569         TInt numLines = iEditor->TextLayout()->NumFormattedLines();
  1581         TInt numLines = iEditor->TextLayout()->NumFormattedLines();
  1570         if(numLines == iEditor->MaximumHeightInLines())
  1582         if (numLines == iEditor->MaximumHeightInLines())
  1571         {
  1583         {
  1572             if(iEditor->ScrollBarFrame())
  1584             if (iEditor->ScrollBarFrame())
  1573             {
  1585             {
  1574                 iEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff);
  1586                 iEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff);
  1575             }
  1587             }
  1576         }
  1588         }
  1577         else if(numLines > iEditor->MaximumHeightInLines())
  1589         else if (numLines > iEditor->MaximumHeightInLines())
  1578         {
  1590         {
  1579             if(!iEditor->ScrollBarFrame())
  1591             if (!iEditor->ScrollBarFrame())
  1580             {
  1592             {
  1581                 iEditor->CreatePreAllocatedScrollBarFrameL();
  1593                 iEditor->CreatePreAllocatedScrollBarFrameL();
  1582                 iEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
  1594                 iEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
  1583             }
  1595             }
  1584             TRect editorRect = iEditor->Rect();
  1596             TRect editorRect = iEditor->Rect();
  1585             if(iEditor->ScrollBarFrame()->VerticalScrollBar())
  1597             if (iEditor->ScrollBarFrame()->VerticalScrollBar())
  1586             {
  1598             {
  1587                 editorRect.SetWidth(editorRect.Width() - iEditor->ScrollBarFrame()->VerticalScrollBar()->ScrollBarBreadth());
  1599                 editorRect.SetWidth(editorRect.Width() - iEditor->ScrollBarFrame()->VerticalScrollBar()->ScrollBarBreadth());
  1588                 iEditor->SetRect(editorRect);
  1600                 iEditor->SetRect(editorRect);
  1589             }
  1601             }
  1590         }
  1602         }
  1591     }
  1603     }
  1592 }
  1604 }
       
  1605 
       
  1606 void CMIDTextBoxQueryDialog::PreLayoutDynInitL()
       
  1607 {
       
  1608     CAknQueryDialog::PreLayoutDynInitL();
       
  1609     UpdateLeftSoftKeyL();
       
  1610 }
  1593 // End of file
  1611 // End of file