mpxplugins/viewplugins/views/commoncontainer/src/mpxcommoncontainersearchfield.cpp
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class that implements Search Field feature.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <eikmenub.h>
       
    21 #include <eikdef.h>
       
    22 #include <akninfrm.h>
       
    23 #include <eikon.rsg>
       
    24 #include <eikenv.h>
       
    25 #include <txtglobl.h>
       
    26 #include <gulfont.h>
       
    27 #include <txtfrmat.h>
       
    28 #include <eikgted.h>
       
    29 #include <aknconsts.h>
       
    30 #include <akneditstateindicator.h>
       
    31 #include <aknslistboxbackgroundcontrolcontext.h>
       
    32 #include <aknlayout2def.h>
       
    33 #include <aknlayout2scalabledef.h>
       
    34 #include <aknlayoutscalable_avkon.cdl.h>
       
    35 #include <featmgr.h>
       
    36 #include <fepbase.h>
       
    37 #include <aknutils.h>
       
    38 #include "mpxcommoncontainersearchfieldwrapper.h"
       
    39 #include "mpxcommoncontainersearchfield.h"
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CMPXCommonContainerSearchField* CMPXCommonContainerSearchField::NewL(
       
    46     CMPXCommonContainerSearchFieldWrapper* aParent,
       
    47     TBool aFindKeywordMode )
       
    48     {
       
    49     CMPXCommonContainerSearchField* self = new (ELeave) CMPXCommonContainerSearchField( aFindKeywordMode );
       
    50     CleanupStack::PushL( self );
       
    51 
       
    52     self->ConstructL( aParent );
       
    53     self->MakeVisibleL( EFalse );
       
    54     self->SetFocus( EFalse );
       
    55 
       
    56     CleanupStack::Pop( self );
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void CMPXCommonContainerSearchField::MakeVisibleL( TBool aVisible )
       
    65     {
       
    66     if ( aVisible )
       
    67         {
       
    68         HandleFindSizeChanged();
       
    69         SetTextL( KNullDesC );
       
    70         }
       
    71 
       
    72     // if ( AknLayoutUtils::PenEnabled() )
       
    73         // {
       
    74         // Note, commented out, caused LSK and RSK problems.
       
    75         // SetPointerCapture( aVisible );
       
    76         // Note, commented out, activated Virtual KeyBoard right away.
       
    77         // if ( aVisible )
       
    78             // {
       
    79             // ActivateVkbL();
       
    80             // }
       
    81         // }
       
    82 
       
    83     CCoeControl::MakeVisible( aVisible );
       
    84 
       
    85     iSearchFieldKeyHandler->Reset();
       
    86     iSearchFieldKeyHandler->EnableL( aVisible );
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CMPXCommonContainerSearchField::MakeVisible( TBool aVisible )
       
    94     {
       
    95     TRAP_IGNORE( MakeVisibleL( aVisible ) );
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 CMPXCommonContainerSearchField::~CMPXCommonContainerSearchField()
       
   103     {
       
   104     delete iSearchFieldKeyHandler;
       
   105     delete iEditor;
       
   106     delete iInputFrame;
       
   107 	delete iPrevKeyword;
       
   108 	CCoeEnv::Static()->RemoveFepObserver(
       
   109 	    static_cast<MCoeFepObserver &>( *this ) );
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 CMPXCommonContainerSearchField::CMPXCommonContainerSearchField( TBool aFindKeywordMode )
       
   117  :  iFindKeywordMode( aFindKeywordMode ),
       
   118     iHandleFEPFind( ETrue )
       
   119     {
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void CMPXCommonContainerSearchField::ConstructL( CMPXCommonContainerSearchFieldWrapper* aParent )
       
   127     {
       
   128     CreateWindowL();
       
   129 
       
   130     SetMopParent( aParent );
       
   131     iParent = aParent;
       
   132 
       
   133     iEditor = new (ELeave) CEikGlobalTextEditor;
       
   134 
       
   135     iInputFrame = CAknInputFrame::NewL( iEditor,
       
   136                                         EFalse,
       
   137                                         KAvkonBitmapFile,
       
   138                                         EMbmAvkonQgn_indi_find_glass,
       
   139                                         EMbmAvkonQgn_indi_find_glass_mask,
       
   140                                         CAknInputFrame::EPopupLayout );
       
   141     iInputFrame->SetContainerWindowL( *this );
       
   142 
       
   143     AknEditUtils::ConstructEditingL ( iEditor,
       
   144                                       40, // TODO
       
   145                                       1,
       
   146                                       EAknEditorCharactersLowerCase,
       
   147                                       EAknEditorAlignRight,
       
   148                                       EFalse,
       
   149                                       ETrue,
       
   150                                       EFalse );
       
   151     iEditor->SetContainerWindowL( *this );
       
   152     iEditor->SetObserver( this );
       
   153     iEditor->SetBorder( TGulBorder::ENone );
       
   154     iEditor->SetAknEditorCase( EAknEditorLowerCase );
       
   155     iEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
       
   156 
       
   157     // Disallow chinese input.
       
   158     if ( FeatureManager::FeatureSupported( KFeatureIdAvkonApac ) )
       
   159         {
       
   160         iEditor->SetAknEditorAllowedInputModes( EAknEditorTextInputMode |
       
   161                                                 EAknEditorNumericInputMode );
       
   162         }
       
   163 
       
   164     // Find keyword should use EAknEditorFlagDefault since in find
       
   165     // input we allow all types of input.
       
   166    	iEditor->SetAknEditorFlags( ( ( iFindKeywordMode ) ?
       
   167    	                                    EAknEditorFlagDefault :
       
   168    	                                    EAknEditorFlagLatinInputModesOnly ) |
       
   169    	                            EAknEditorFlagUseSCTNumericCharmap );
       
   170     iEditor->SetAknEditorPermittedCaseModes( EAknEditorUpperCase |
       
   171                                              EAknEditorLowerCase );
       
   172 
       
   173     iSearchFieldKeyHandler = new (ELeave) CMPXCommonContainerSearchFieldKeyHandler( *this );
       
   174 
       
   175     /* TODO?
       
   176     iAvkonAppUi->AddToStackL( iSearchFieldKeyHandler,
       
   177                               ECoeStackPriorityFep + 1,
       
   178                               ECoeStackFlagRefusesFocus );
       
   179     */
       
   180 
       
   181     iEditor->SetEdwinObserver( iSearchFieldKeyHandler );
       
   182 	iEditor->SetSkinBackgroundControlContextL( NULL );
       
   183 
       
   184 	CCoeEnv::Static()->AddFepObserverL(
       
   185 	    static_cast<MCoeFepObserver &>( *this ) );
       
   186 
       
   187 	iPrevKeyword = KNullDesC().AllocL();
       
   188     }
       
   189 
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 void CMPXCommonContainerSearchField::SetOrdinalPosition( TInt aPos )
       
   195     {
       
   196     Window().SetOrdinalPosition( aPos );
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 void CMPXCommonContainerSearchField::HandleFindSizeChanged()
       
   204     {
       
   205     if ( IsVisible() )
       
   206         {
       
   207         TRect searchRect = iParent->GetSearchFieldRect( ETrue,
       
   208                                                         iParent->ClientRect() );
       
   209         AknLayoutUtils::LayoutControl( this,
       
   210                                        searchRect,
       
   211                                        AknLayout::popup_find_window() );
       
   212         }
       
   213     }
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 //
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 void CMPXCommonContainerSearchField::EnableKeyEventHandlerL( TBool aEnable )
       
   220     {
       
   221     iSearchFieldKeyHandler->EnableL( aEnable );
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 //
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 void CMPXCommonContainerSearchField::HandleControlEventL( CCoeControl* /*aControl*/,
       
   229                                              TCoeEvent aEventType )
       
   230     {
       
   231 	if ( iFindKeywordMode )
       
   232 		{
       
   233 	    if ( iEditor->AknEditorCurrentInputMode() == EAknEditorCalculatorNumberModeKeymap
       
   234             // When the user copies and paste's content to the find dialog, the editor
       
   235             // is in Text Input mode, The engine should still get the find keyword request
       
   236             || iEditor->AknEditorCurrentInputMode() == EAknEditorTextInputMode )
       
   237 	    	{
       
   238 		    if ( aEventType == MCoeControlObserver::EEventStateChanged )
       
   239 		        {
       
   240 		        HBufC* newText = GetTextLC();
       
   241 		        if ( ! newText )
       
   242 		            {
       
   243 		            newText = KNullDesC().AllocLC();
       
   244 		            }
       
   245 
       
   246 		        if ( iPrevKeyword->Compare( *newText ) != 0 )
       
   247 		        	{
       
   248 		            delete iPrevKeyword;
       
   249 		            iPrevKeyword = newText;
       
   250 		            CleanupStack::Pop( newText );
       
   251 
       
   252 					iParent->FindKeywordL( *newText );
       
   253 
       
   254 					iHandleFEPFind = EFalse;
       
   255 		        	}
       
   256 				else
       
   257 					{
       
   258 					CleanupStack::PopAndDestroy( newText );
       
   259 					}
       
   260 		        }
       
   261 	    	}
       
   262 		}
       
   263 
       
   264     if ( aEventType == EEventRequestFocus )
       
   265         {
       
   266         FocusChanged( EDrawNow );
       
   267         }
       
   268     }
       
   269 
       
   270 // ----------------------------------------------------------------------------
       
   271 //
       
   272 // ----------------------------------------------------------------------------
       
   273 //
       
   274 TKeyResponse CMPXCommonContainerSearchField::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   275                                                 TEventCode aType )
       
   276     {
       
   277     // Escape key event handling.
       
   278     if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape )
       
   279         {
       
   280         // TODO: Check that closing Search Field goes ok with this case.
       
   281 
       
   282         CCoeEnv::Static()->AppUi()->RemoveFromStack( this );
       
   283         MakeVisible( EFalse );
       
   284         SetFocus( EFalse );
       
   285         return EKeyWasConsumed;
       
   286         }
       
   287 
       
   288 	if ( aType == EEventKey )
       
   289 		{
       
   290 		/* TODO: This feature not needed?
       
   291 		// Handle up and down arow keys to search for next and previous keywords.
       
   292 		if ( aKeyEvent.iCode == EKeyUpArrow )
       
   293 			{
       
   294 			// Find previous keyword.
       
   295 			iParent->FindKeywordL( NULL, EFalse );
       
   296 			iHandleFEPFind = EFalse;
       
   297 			return EKeyWasConsumed;
       
   298 			}
       
   299 		if ( aKeyEvent.iCode == EKeyDownArrow )
       
   300 			{
       
   301 			// Find next keyword.
       
   302 			iParent->FindKeywordL( NULL, ETrue );
       
   303 			iHandleFEPFind = EFalse;
       
   304 			return EKeyWasConsumed;
       
   305 			}
       
   306 		*/
       
   307 		}
       
   308 
       
   309 	return iEditor->OfferKeyEventL( aKeyEvent, aType );
       
   310 	}
       
   311 
       
   312 // ----------------------------------------------------------------------------
       
   313 //
       
   314 // ----------------------------------------------------------------------------
       
   315 //
       
   316 void CMPXCommonContainerSearchField::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   317     {
       
   318     if ( ! AknLayoutUtils::PenEnabled() )
       
   319         {
       
   320         return;
       
   321         }
       
   322 
       
   323     // Pointer is inside the Search Field.
       
   324     if ( Rect().Contains( aPointerEvent.iPosition ) )
       
   325         {
       
   326         iSearchFieldKeyHandler->EnableL( ETrue );
       
   327         iEditor->HandlePointerEventL( aPointerEvent );
       
   328         iSearchFieldKeyHandler->SetFirstKeyEvent( EFalse );
       
   329         }
       
   330     else
       
   331         {
       
   332         // Pointer outside of control, close control?
       
   333         }
       
   334     }
       
   335 
       
   336 // ----------------------------------------------------------------------------
       
   337 //
       
   338 // ----------------------------------------------------------------------------
       
   339 //
       
   340 TInt CMPXCommonContainerSearchField::CountComponentControls() const
       
   341     {
       
   342     return 2; // iEditor and iInputFrame.
       
   343     }
       
   344 
       
   345 // ----------------------------------------------------------------------------
       
   346 //
       
   347 // ----------------------------------------------------------------------------
       
   348 //
       
   349 CCoeControl* CMPXCommonContainerSearchField::ComponentControl( TInt aIndex ) const
       
   350     {
       
   351     switch ( aIndex )
       
   352         {
       
   353         case 0:
       
   354             {
       
   355 			return iInputFrame;
       
   356             }
       
   357         case 1:
       
   358             {
       
   359             return iEditor;
       
   360             }
       
   361         default:
       
   362             {
       
   363             return NULL;
       
   364             }
       
   365         }
       
   366     }
       
   367 
       
   368 // ----------------------------------------------------------------------------
       
   369 //
       
   370 // ----------------------------------------------------------------------------
       
   371 //
       
   372 void CMPXCommonContainerSearchField::SizeChanged()
       
   373     {
       
   374     iInputFrame->SetRect( Rect() );
       
   375     }
       
   376 
       
   377 // ----------------------------------------------------------------------------
       
   378 //
       
   379 // ----------------------------------------------------------------------------
       
   380 //
       
   381 void CMPXCommonContainerSearchField::FocusChanged( TDrawNow aDrawNow )
       
   382     {
       
   383     // this is a workaround
       
   384     TRAP_IGNORE( iSearchFieldKeyHandler->EnableL( IsFocused() ) );
       
   385     CCoeControl::FocusChanged( aDrawNow );
       
   386     iEditor->SetFocus( IsFocused() );
       
   387     }
       
   388 
       
   389 // ----------------------------------------------------------------------------
       
   390 //
       
   391 // ----------------------------------------------------------------------------
       
   392 //
       
   393 TInt CMPXCommonContainerSearchField::TextLength() const
       
   394     {
       
   395     return iEditor->TextLength();
       
   396     }
       
   397 
       
   398 // ----------------------------------------------------------------------------
       
   399 //
       
   400 // ----------------------------------------------------------------------------
       
   401 //
       
   402 HBufC* CMPXCommonContainerSearchField::GetTextLC() const
       
   403     {
       
   404     HBufC *retVal = NULL;
       
   405 
       
   406     if ( TextLength() || iFindKeywordMode )
       
   407         {
       
   408         retVal = HBufC::NewLC( TextLength() + 1 );
       
   409         TPtr ptr = retVal->Des();
       
   410         iEditor->GetText( ptr );
       
   411         ptr.ZeroTerminate();
       
   412         }
       
   413 
       
   414     return retVal;
       
   415     }
       
   416 
       
   417 // ----------------------------------------------------------------------------
       
   418 //
       
   419 // ----------------------------------------------------------------------------
       
   420 //
       
   421 void CMPXCommonContainerSearchField::SetTextL( const TDesC& aTxt )
       
   422     {
       
   423     iEditor->SetTextL( &aTxt );
       
   424 
       
   425     TInt curPos = TextLength();
       
   426     iEditor->SetSelectionL( curPos, curPos );
       
   427 	iEditor->DrawNow();
       
   428     }
       
   429 
       
   430 // ----------------------------------------------------------------------------
       
   431 //
       
   432 // ----------------------------------------------------------------------------
       
   433 //
       
   434 void CMPXCommonContainerSearchField::SelectAllL()
       
   435     {
       
   436     iEditor->SelectAllL();
       
   437     }
       
   438 
       
   439 // ----------------------------------------------------------------------------
       
   440 //
       
   441 // ----------------------------------------------------------------------------
       
   442 //
       
   443 void CMPXCommonContainerSearchField::SetInfoTextL( const TDesC& aText )
       
   444     {
       
   445     iInputFrame->SetInfoTextL( aText );
       
   446     }
       
   447 
       
   448 // ----------------------------------------------------------------------------
       
   449 //
       
   450 // ----------------------------------------------------------------------------
       
   451 //
       
   452 void CMPXCommonContainerSearchField::ClipboardL( CEikEdwin::TClipboardFunc aClipboardFunc )
       
   453     {
       
   454     iEditor->ClipboardL( aClipboardFunc );
       
   455     }
       
   456 
       
   457 // ----------------------------------------------------------------------------
       
   458 //
       
   459 // ----------------------------------------------------------------------------
       
   460 CEikEdwin* CMPXCommonContainerSearchField::Editor() const
       
   461     {
       
   462     return iEditor;
       
   463     }
       
   464 
       
   465 // ----------------------------------------------------------------------------
       
   466 //
       
   467 // ----------------------------------------------------------------------------
       
   468 //
       
   469 CMPXCommonContainerSearchFieldKeyHandler::CMPXCommonContainerSearchFieldKeyHandler( CMPXCommonContainerSearchField& aSearchField )
       
   470  :  iEnabled( EFalse ),
       
   471     iFirstKeyEvent( ETrue ),
       
   472     iLeftRightEvent ( EFalse ),
       
   473     iSearchField( aSearchField )
       
   474     {
       
   475     }
       
   476 
       
   477 // ----------------------------------------------------------------------------
       
   478 //
       
   479 // ----------------------------------------------------------------------------
       
   480 //
       
   481 TKeyResponse CMPXCommonContainerSearchFieldKeyHandler::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   482                                                           TEventCode aType )
       
   483     {
       
   484     TKeyResponse response( EKeyWasNotConsumed );
       
   485     iLeftRightEvent = EFalse;
       
   486 
       
   487     if ( iEnabled && aType == EEventKey )
       
   488         {
       
   489         switch( aKeyEvent.iCode )
       
   490             {
       
   491             case EKeyUpArrow:
       
   492             case EKeyDownArrow:
       
   493                 {
       
   494                 iFirstKeyEvent = EFalse;
       
   495                 break;
       
   496                 }
       
   497 
       
   498             case EKeyLeftArrow:
       
   499             case EKeyRightArrow:
       
   500                 {
       
   501                 iFirstKeyEvent = EFalse;
       
   502                 iLeftRightEvent = ETrue;
       
   503 
       
   504 				// Below added to compensate for a weird key event situation:
       
   505 				//   For some reason the CMPXCommonContainerSearchField::OfferKeyEventL function
       
   506 				//   is not being called for an EEventKey when you press the left/right
       
   507 				//   arrows in the menupane produced to paste previously used special
       
   508 				//   chars (this is brought up by pressing the pen button on the phone).
       
   509 				//   This only happens when the cursor is in the first or last position in
       
   510 				//   the Search Field with text in it.
       
   511 				//   Therefore, in this particular scenario, we need to process the EEventKey
       
   512 				//   here since we will not be able to in CMPXCommonContainerSearchField::OfferKeyEventL
       
   513                 // TODO if ( CBrowserAppUi::Static()->ContentView()->MenuBar()->MenuPane()->IsFocused())
       
   514 		        // TODO    {
       
   515 		        // TODO    response = CBrowserAppUi::Static()->ContentView()->MenuBar()->MenuPane()->OfferKeyEventL( aKeyEvent, aType );
       
   516 		        // TODO    }
       
   517                 break;
       
   518                 }
       
   519 
       
   520             case EKeyBackspace:
       
   521             case EKeyDelete:
       
   522                 {
       
   523                 if ( iFirstKeyEvent )
       
   524                     {
       
   525                     iFirstKeyEvent = EFalse;
       
   526                     iCoeEnv->SimulateKeyEventL( aKeyEvent, aType );
       
   527                     response = EKeyWasConsumed;
       
   528                     }
       
   529                 break;
       
   530                 }
       
   531 
       
   532             default:
       
   533                 {
       
   534                 if ( iFirstKeyEvent )
       
   535                     {
       
   536                     if ( TChar( aKeyEvent.iCode ).IsPrint() )
       
   537                         {
       
   538                         iFirstKeyEvent = EFalse;
       
   539                         response = EKeyWasConsumed;
       
   540                         iCoeEnv->SimulateKeyEventL( aKeyEvent, aType );
       
   541                         }
       
   542                     }
       
   543                 break;
       
   544                 }
       
   545             }
       
   546         }
       
   547 
       
   548     return response;
       
   549     }
       
   550 
       
   551 // ----------------------------------------------------------------------------
       
   552 //
       
   553 // ----------------------------------------------------------------------------
       
   554 //
       
   555 void CMPXCommonContainerSearchFieldKeyHandler::HandleEdwinEventL( CEikEdwin* /*aEdwin*/,
       
   556                                                      TEdwinEvent aEventType )
       
   557     {
       
   558     if ( aEventType == EEventTextUpdate )
       
   559         {
       
   560         // if text changed in the editor we don't have to handle clear key anymore.
       
   561         iFirstKeyEvent = EFalse;
       
   562 
       
   563         // For some reason typing letters on the qwerty keyboard of one product
       
   564         // does not trigger the HandleCompletionOfTransactionL() or the
       
   565         // HandleControlEventL(). Therefore we must check the text here.
       
   566         iSearchField.UpdateFindKeywordL();
       
   567         }
       
   568     }
       
   569 
       
   570 // ----------------------------------------------------------------------------
       
   571 //
       
   572 // ----------------------------------------------------------------------------
       
   573 //
       
   574 void CMPXCommonContainerSearchFieldKeyHandler::EnableL( TBool aEnable )
       
   575     {
       
   576     iEnabled = aEnable;
       
   577     }
       
   578 
       
   579 // ----------------------------------------------------------------------------
       
   580 //
       
   581 // ----------------------------------------------------------------------------
       
   582 //
       
   583 void CMPXCommonContainerSearchFieldKeyHandler::Reset()
       
   584     {
       
   585     iFirstKeyEvent = ETrue;
       
   586     }
       
   587 	
       
   588 // ---------------------------------------------------------------------------
       
   589 //
       
   590 // ---------------------------------------------------------------------------
       
   591 //
       
   592 TBool CMPXCommonContainerSearchFieldKeyHandler::IsLeftRightEvent()
       
   593     {
       
   594     return iLeftRightEvent;
       
   595     }
       
   596 
       
   597 // ---------------------------------------------------------------------------
       
   598 //
       
   599 // ---------------------------------------------------------------------------
       
   600 //
       
   601 void CMPXCommonContainerSearchFieldKeyHandler::SetFirstKeyEvent( TBool aFirstKeyEvent )
       
   602     {
       
   603     iFirstKeyEvent = aFirstKeyEvent;
       
   604     }
       
   605 
       
   606 // ---------------------------------------------------------------------------
       
   607 //
       
   608 // ---------------------------------------------------------------------------
       
   609 //
       
   610 void CMPXCommonContainerSearchField::HandleResourceChange( TInt aType )
       
   611 	{
       
   612 	CCoeControl::HandleResourceChange( aType );
       
   613 	}
       
   614 
       
   615 // ---------------------------------------------------------------------------
       
   616 //
       
   617 // ---------------------------------------------------------------------------
       
   618 //
       
   619 void CMPXCommonContainerSearchField::HandleStartOfTransactionL()
       
   620 	{
       
   621 	}
       
   622 
       
   623 // ---------------------------------------------------------------------------
       
   624 //
       
   625 // ---------------------------------------------------------------------------
       
   626 //
       
   627 void CMPXCommonContainerSearchField::HandleCompletionOfTransactionL()
       
   628 	{
       
   629 	if ( iParent && iFindKeywordMode && this->IsVisible() && iHandleFEPFind )
       
   630 		{
       
   631 		UpdateFindKeywordL();
       
   632 		}
       
   633 
       
   634     iHandleFEPFind = ETrue;
       
   635 	}
       
   636 
       
   637 // ----------------------------------------------------------------------------
       
   638 // Simulates pointer event to force VKB.
       
   639 // ----------------------------------------------------------------------------
       
   640 //
       
   641 void CMPXCommonContainerSearchField::ActivateVkbL()
       
   642     {
       
   643     if ( iEditor && iEditor->TextView() )
       
   644         {
       
   645         // Make sure observer is set.
       
   646         iCoeEnv->SyncNotifyFocusObserversOfChangeInFocus();
       
   647 
       
   648        	// First get point at cursor location.
       
   649         TInt pos = iEditor->CursorPos();
       
   650        	CTextView* textView = iEditor->TextView();
       
   651        	TPoint curPos;
       
   652        	textView->DocPosToXyPosL( pos, curPos );
       
   653 
       
   654        	TPointerEvent pe;
       
   655        	pe.iPosition = curPos;
       
   656 
       
   657        	pe.iType = TPointerEvent::EButton1Down;
       
   658        	iEditor->HandlePointerEventL( pe );
       
   659 
       
   660         // VKB will only activate is nothing selected
       
   661         iEditor->SetSelectionL( pos, pos );
       
   662 
       
   663        	pe.iType = TPointerEvent::EButton1Up;
       
   664        	iEditor->HandlePointerEventL( pe );
       
   665         }
       
   666     }
       
   667 
       
   668 // ----------------------------------------------------------------------------
       
   669 //
       
   670 // ----------------------------------------------------------------------------
       
   671 //
       
   672 void CMPXCommonContainerSearchField::UpdateFindKeywordL()
       
   673     {
       
   674     HBufC* newKeyword = GetTextLC();
       
   675 
       
   676     if ( newKeyword->Compare( *iPrevKeyword ) != 0 )
       
   677         {
       
   678         delete iPrevKeyword;
       
   679         iPrevKeyword = newKeyword;
       
   680         CleanupStack::Pop( newKeyword );
       
   681 
       
   682         iParent->FindKeywordL( *newKeyword );
       
   683         }
       
   684     else
       
   685         {
       
   686         CleanupStack::PopAndDestroy( newKeyword );
       
   687         }
       
   688     }