uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 64 85902f042028
parent 59 978afdc0236f
child 72 a5e7a4f63858
--- a/uifw/ganes/src/HgScroller.cpp	Tue Sep 14 21:48:24 2010 +0300
+++ b/uifw/ganes/src/HgScroller.cpp	Wed Sep 15 12:29:17 2010 +0300
@@ -891,6 +891,7 @@
     
     iPointerDown = EFalse;
     iPanning = EFalse;
+    iEnterKeyHandled = EFalse;
     }
 
 // -----------------------------------------------------------------------------
@@ -1061,33 +1062,37 @@
     iViewPosition = aNewPosition;
     iPhysics->StopPhysics();
     
-    if( iScrollBarType == EHgScrollerTimeStrip )
+    // show a letter popup only if we are currently dragging with scrollbar
+    if(iScrollbar && iScrollbar->IsDragging())
         {
-        // Show first item's time.
-        TInt selectedItem = CurrentIndex();
-        if( selectedItem >= 0 && selectedItem < iItems.Count()
-                && iItems[selectedItem]->Time().Int64() )
+        if( iScrollBarType == EHgScrollerTimeStrip )
             {
-            TRAP_IGNORE(
-                    iItems[selectedItem]->Time().FormatL( iPopupText1, KGanesMonthString );
-                    iItems[selectedItem]->Time().FormatL( iPopupText2, KGanesYearString );
-                )
-            // To display month and year correctly in arabic.
-            AknTextUtils::LanguageSpecificNumberConversion( iPopupText1 );
-            AknTextUtils::LanguageSpecificNumberConversion( iPopupText2 );
+            // Show first item's time.
+            TInt selectedItem = CurrentIndex();
+            if( selectedItem >= 0 && selectedItem < iItems.Count()
+                    && iItems[selectedItem]->Time().Int64() )
+                {
+                TRAP_IGNORE(
+                        iItems[selectedItem]->Time().FormatL( iPopupText1, KGanesMonthString );
+                        iItems[selectedItem]->Time().FormatL( iPopupText2, KGanesYearString );
+                    )
+                // To display month and year correctly in arabic.
+                AknTextUtils::LanguageSpecificNumberConversion( iPopupText1 );
+                AknTextUtils::LanguageSpecificNumberConversion( iPopupText2 );
+                }
             }
-        }
-    else if( iScrollBarType == EHgScrollerLetterStrip
-            || iScrollBarType == EHgScrollerLetterStripLite )
-        {
-        TInt selectedItem = CurrentIndex();
-        if( selectedItem >= 0 && selectedItem < iItems.Count() )
+        else if( iScrollBarType == EHgScrollerLetterStrip
+                || iScrollBarType == EHgScrollerLetterStripLite )
             {
-            if(iItems[selectedItem]->Title().Length())
+            TInt selectedItem = CurrentIndex();
+            if( selectedItem >= 0 && selectedItem < iItems.Count() )
                 {
-                iPopupText1.Zero();
-                iPopupText1.Append( iItems[selectedItem]->Title()[0] );
-                iPopupText1.UpperCase();
+                if(iItems[selectedItem]->Title().Length())
+                    {
+                    iPopupText1.Zero();
+                    iPopupText1.Append( iItems[selectedItem]->Title()[0] );
+                    iPopupText1.UpperCase();
+                    }
                 }
             }
         }
@@ -1191,24 +1196,46 @@
         case EKeyEnter:
         case EKeyOK:
             {
-            if( iSelectedIndex != KErrNotFound && HasHighlight() )
+            // If enter key is pushed down for a long time, many key events
+            // are generated. Enter should be handled only ones.
+            if (!iEnterKeyHandled)
                 {
-                iShowHighlight = EFalse;
-                iDrawUtils->EnableMarquee(HasHighlight());
-                if( iSelectionObserver )
-                    TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
-                return EKeyWasConsumed;
-                }
-            else if( iItemCount )
-                {
-                iSelectedIndex = CurrentIndex();
-                FitSelectionToView();
-                iShowHighlight = ETrue;
-                iDrawUtils->EnableMarquee(HasHighlight());
-                DrawDeferred();
-                if( iSelectionObserver )
-                    TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
-                return EKeyWasConsumed;
+                iEnterKeyHandled = ETrue;
+                if( iSelectedIndex != KErrNotFound && HasHighlight())
+                    {                
+                    iEnterKeyHandled = ETrue;
+                    const TBool validIndex = iSelectedIndex >= 0 && iSelectedIndex < iItems.Count();
+                    const TBool selectionMode = iFlags & EHgScrollerSelectionMode;
+                    if (validIndex && selectionMode)
+                        {
+                        // In selection mode enterkey should mark/unmark item.
+                        iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked ? 
+                            UnMark(iSelectedIndex) : Mark(iSelectedIndex);
+                        DrawDeferred();
+                        }
+                    else
+                        {
+                        // Item will be opened so highlight is removed.
+                        iShowHighlight = EFalse;
+                        if( iSelectionObserver )
+                            {
+                            TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
+                            }
+                        }
+                    iDrawUtils->EnableMarquee(HasHighlight());
+                    return EKeyWasConsumed;
+                    }
+                else if( iItemCount )
+                    {
+                    iSelectedIndex = CurrentIndex();
+                    FitSelectionToView();
+                    iShowHighlight = ETrue;
+                    iDrawUtils->EnableMarquee(HasHighlight());
+                    DrawDeferred();
+                    if( iSelectionObserver )
+                        TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
+                    return EKeyWasConsumed;
+                    }
                 }
             return EKeyWasNotConsumed;
             }
@@ -1280,7 +1307,9 @@
         iHighlightTimer->Cancel();
         iPointerDown = EFalse;
         if(iDetector)
-            iDetector->CancelAnimationL();
+            {
+            TRAP_IGNORE(iDetector->CancelAnimationL());
+            }
         iPanning = EFalse;
     
         iPhysics->StopPhysics();