×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    Construct CAknPopupFieldText programmatically

    I want to put a CAknPopupFieldText in a view that is not derived from CAknForm .

    I have tried defining a dummy popup resource:

    Code:
    RESOURCE ARRAY r_array_eventos
    	{
    	items=
    		{
    		LBUF
    			{
    			txt = STR_popup_empty;
    			}
    		};
    	}
    RESOURCE POPUP_FIELD_TEXT r_popup_control
    	{
    	popupfield = POPUP_FIELD{};
    	textarray = r_array_eventos;
    	active = 0;
    	}
    then building it in the InitializeControlsL() of the control container with the following code:

    Code:
    	iEventoPopup = new (ELeave) CAknPopupFieldText;
    		{
    		TResourceReader reader;
    		iEikonEnv->CreateResourceReaderLC( reader, R_POPUP_CONTROL );
    		iEventoPopup->ConstructFromResourceL( reader );
    		CleanupStack::PopAndDestroy(); // reader internal state
    		}
    	MDesC16Array* aMDesC16Array = (MDesC16Array*) (iEventoPopup->MdcArray());
    	CAknQueryValueTextArray* aTextArray = static_cast <CAknQueryValueTextArray*> (aMDesC16Array);
    	aTextArray->SetArray(*iEventList);    // 1 to 12 items in iEventList
    	iEventoPopup->SetCurrentValueIndex(0);
    	iEventoPopup->SetFont( iFont );
    	iEventoPopup->SetFocusing(ETrue);
    	iEventoPopup->MakeVisible(ETrue);
    //	iEventoPopup->ActivateSelectionListL();  // Crashes here if this line is not commented
    finally laying the control out in LayOutControls()

    Code:
    iEventoPopup->SetExtent(TPoint(x_margin_label, y), TSize(180, 32));
    The view displays all the other controls but the popup is not visible at all.
    I can't find anywhere how a control like this is created 100% programmatically and outside a CAknForm derived object.
    ----------------------------------------------
    Every journey starts with a small step.

  2. #2
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    Re: Construct CAknPopupFieldText programmatically

    Since no one seems to know how to solve this in a simple way (and the example in the SDK is ridiculously complex), I decided to implement the popup inside a form.
    The PreLayoutDynInitL() is quite simple:

    Code:
    void CSeguridadSymbianEscoltaAccion::PreLayoutDynInitL()
    	{
    	iEventList = new (ELeave)  CDesCArrayFlat (KMaxNumberEvents);
    	GetLabelsFromLoginResponse();
    	// [[[ begin generated region: do not modify [Generated Contents]
    	iPopupAcciones = static_cast< CAknPopupFieldText* >( 
    		ControlOrNull( ESeguridadSymbianEscoltaAccionViewPopupAcciones ) );
    	iPopupAcciones->SetFont( iEikonEnv->NormalFont() );
    	AddControlEventHandlerL( 
    			iPopupAcciones, 
    			EEventStateChanged, 
    			&CSeguridadSymbianEscoltaAccion::HandlePopupAccionesStateChangedL );
    	// ]]] end generated region [Generated Contents]
    	MDesC16Array* aMDesC16Array = (MDesC16Array*) (iPopupAcciones->MdcArray());
    	CAknQueryValueTextArray* aTextArray = static_cast <CAknQueryValueTextArray*> (aMDesC16Array);
    	aTextArray->SetArray(*iEventList);
    	iPopupAcciones->SetCurrentValueIndex(0);
    	//	Change CBA
    	CEikButtonGroupContainer *cba = CEikButtonGroupContainer::Current();
    	CleanupStack::PushL(cba);
    	cba->SetCommandSetL(R_SEGURIDAD_SYMBIAN_ESCOLTA_ACCION_CBA);
    	cba->MakeVisible( ETrue );
    	CleanupStack::Pop();
    	LoadFromDataL();
    	}
    I just add items in the popup programmatically, and change the CBA.

    When the view that contains the form is activated, the form displays, but the popup is not visible at all. However, it is there 'cause it is responding to state changes. I suspect that the font is the same color of the background (white in my case), but I don't know why. Anyone has a clue on how to verify / change the font color inside PreLayoutDynInitL()
    ----------------------------------------------
    Every journey starts with a small step.

Similar Threads

  1. Sending image programmatically, fallback using default email client?
    By tvinke in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2008-10-01, 14:20
  2. Replies: 1
    Last Post: 2007-10-12, 08:31
  3. how to enable disable btstack programmatically
    By kpmkhaja1 in forum Bluetooth Technology
    Replies: 2
    Last Post: 2006-09-19, 14:58
  4. How to close pop up dialog programmatically
    By S.S.Sudhakar in forum Symbian
    Replies: 2
    Last Post: 2006-07-27, 03:38
  5. Replies: 0
    Last Post: 2006-03-05, 00:50

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×