Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User mikedeklerk's Avatar
    Join Date
    Jan 2008
    Posts
    46
    Hi All,

    I am very new to Symbian C++ programming in Carbide.C++ and I am trying to get the principles and concepts.

    I have a project with uiDesigner. I have inserted a globalnote and an optionsmenu. And I have dragged a Text Editor into my designform.

    In a file called FirstContainer.cpp (my app its name is "First") I have seen that the control is initialized with this code:
    Code:
    oid CFirstContainer::InitializeControlsL()
    	{
    	iEdit1 = new ( ELeave ) CEikEdwin;
    	iEdit1->SetContainerWindowL( *this );
    		{
    		TResourceReader reader;
    		iEikonEnv->CreateResourceReaderLC( reader, R_FIRST_CONTAINER_EDIT1 );
    		iEdit1->ConstructFromResourceL( reader );
    		CleanupStack::PopAndDestroy(); // reader internal state
    		}
    		{
    		HBufC* text = StringLoader::LoadLC( R_FIRST_CONTAINER_EDIT1_2 );
    		iEdit1->SetTextL( text );
    		CleanupStack::PopAndDestroy( text );
    		}
    	iEdit1->SetObserver( this );
    	AddControlEventHandlerL( 
    			iEdit1, 
    			EEventStateChanged, 
    			&CFirstContainer::HandleEdit1StateChangedL );
    	
    	iEdit1->SetFocus( ETrue );
    	iFocusControl = iEdit1;
    	
    	}
    When I select the event of an option menu the code for to handle the selection is added to FirstContainerView.cpp (see code below):

    Code:
    TBool CFirstContainerView::HandleDoNowMenuItemSelectedL( TInt aCommand )
    	{
    	// TODO: implement selected event handler
    	
    	_LIT(MyString, "SomeTextHereFucker");
    	CFirstContainerView::RunGlobalNote1L(&MyString);
    	
    	
    	return ETrue;
    	}
    I have seen in FirstContainer.cpp that I can use iEdit1->GetText(); but I can not use this in FirstContainerView.cpp

    Anyway... What I am trying to do is getting the text from the Text Edit control and displaying it with a global note. So I need to obtain the pointer of the text in the Edit Control.

    I have no idea actually where to continue from this.
    Could some please give me some hints/help/code ?

    Thanks for reading, and thanks in advance for replying!

  2. #2
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,672
    one way to figure things out is to check SDK help documentation on the API you are using, Editors in general are quite well documented, so you should find the functions implemented for the class from there.

  3. #3
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    My guess would be that CFirstContainerView contains a pointer to a CFirstContainer, created and deleted in DoActivateL and DoDeactivate.
    So you can access iEdit via that pointer (perhaps iControl or something like that). I do not know the behavior of the Carbide UI designer, but it may have already created public methods for accessing the editor from outside, check if it is true and/or make iEdit1 public (if it is not public by default).

    EDIT: Jukka: the question is more related to the Avkon View architecture (where the controls are owned by the container object, while commands are handled by the view object) than the editors themselves - at least as I see.

  4. #4
    Registered User mikedeklerk's Avatar
    Join Date
    Jan 2008
    Posts
    46
    After Edit:
    Edit:
    I have found this in FirstContainerView.cpp:
    "iFirstContainer->CFirstContainer()->iEdit1->GetText();"
    When I choose GetText(); I can see that its parameter looks like this:
    "GetText(TDes & aDes) void". What kind of variable I have to use there and how to initialize it?

    Before Edit:
    I guess this is the code you meant?
    When I type this "iFirstContainer->" (below the code shown below) I get a list. In this list I can find EEdit1 like "iFirstContainer->EEdit1". But this is also there when I have deleted the edit textbox in the UI designer of carbidee.C++ . So I guess it is has nothing to do with that. I can acces CFirstContainer:: in CFirstContainerView. But the iEdit1->GetText is not there. How should I access that iEdit1 in FirstContainerView from FirstContainer?

    Thanks for helping!


    Code:
    void CFirstContainerView::DoActivateL( 
    		const TVwsViewId& /*aPrevViewId*/,
    		TUid /*aCustomMessageId*/,
    		const TDesC8& /*aCustomMessage*/ )
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	SetupStatusPaneL();
    	
    				
    	if ( iFirstContainer == NULL )
    		{
    		iFirstContainer = CreateContainerL();
    		iFirstContainer->SetMopParent( this );
    		AppUi()->AddToStackL( *this, iFirstContainer );
    		} 
    	// ]]] end generated region [Generated Contents]
    	
    	}
    Last edited by mikedeklerk; 2008-03-17 at 11:27. Reason: Additional information

  5. #5
    Registered User Kavit Patel's Avatar
    Join Date
    Nov 2007
    Posts
    444
    Hi Mike,

    You can use follow:

    TBuf<50> iText;

    iFirstContainer->CFirstContainer()->iEdit1->GetText(iText);


    After this you will have text in the editor into iText variable.
    That you can use in your note.

    Regards,
    Kavit.

  6. #6
    Registered User mikedeklerk's Avatar
    Join Date
    Jan 2008
    Posts
    46
    Thanks for answering my question. So with using TBuf<50> I make a variable with the size for 50 bytes?

    When I copy exactly what you have typed:
    Code:
    TBuf<50> iText;
    
    iFirstContainer->CFirstContainer()->iEdit1->GetText(iText);
    I get an error saying "illegal use of type-name";

    What does that mean? I changed the variable name but that gave the same error so that can not be the case.

    Edit:
    When I try "iFirstContainer->iEdit1->GetText(iText);" I get an error saying: "illegal access from 'CFirstContainer' to protected/private member 'CFirstContainer::iEdit1'"

    thanks again,
    Last edited by mikedeklerk; 2008-03-17 at 12:13.

  7. #7
    Registered User Kavit Patel's Avatar
    Join Date
    Nov 2007
    Posts
    444
    Hi Mike,

    But why you want to access Text editor in Container from View ?

    You can have access it from Container.

    Or you can call some of container's method from view.

    For example.

    from view you can access some public method that returns the TDes.

    void CMyContainer::SomePublicMethod(const TDesC& iText)
    {
    iEdit1->GetText(iText);
    }

    and in view ...
    TBuf <50> iTex;
    iContainer->SomePublicMethod(&iTex);


    Regards,
    Kavit.

  8. #8
    Registered User mikedeklerk's Avatar
    Join Date
    Jan 2008
    Posts
    46
    I was thinking about making a function in container that could return me the text from the textbox in view. When I want to make that function as you suggested it says "unidentified identifier 'SomePublicMethod'"

    Code:
    void CFirstContainer::SomePublicMethod(const TDesC& iText)
    {
    	iEdit1->GetText(iText);
    }
    Thanks again for helping a nagging noob.

  9. #9
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    "const TDesC &iText" does not seem to be an ideal target for GetText, nor an ideal name for an argument, so try "TDes &aText".
    Otherwise you may want to learn C++, where we also declare methods in .h files prior to defining them in the .cpp ones.

Similar Threads

  1. java servlet -> symbian http client, header question
    By s4028469 in forum Mobile Web Site Development
    Replies: 0
    Last Post: 2007-10-17, 02:18
  2. Question about displaying text?
    By Casper1314 in forum Symbian User Interface
    Replies: 1
    Last Post: 2007-04-24, 09:49
  3. Replies: 0
    Last Post: 2004-11-24, 18:49
  4. (hopefully) easy newb question
    By thepts in forum Mobile Java General
    Replies: 5
    Last Post: 2003-08-19, 15:18
  5. 7650 and MS Bluetooth Transceiver
    By damnedi in forum Bluetooth Technology
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved