×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Exclamation CEikRichTextEditor - SetTextL does not work!

    My code to insert text into a CEikRichTextEditor is as follows.

    Code:
    void CPengawasContainer3::ConstructL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	if ( aParent == NULL )
    	    {
    		CreateWindowL();
    	    }
    	else
    	    {
    	    SetContainerWindowL( *aParent );
    	    }
    	iFocusControl = NULL;
    	iCommandObserver = aCommandObserver;
    	InitializeControlsL();
    	iRichTextEditor = new (ELeave)CEikRichTextEditor();
    	iRichTextEditor->SetContainerWindowL(*this);
    	TResourceReader reader;
    	iCoeEnv->CreateResourceReaderLC(reader, R_RICH_TEXT_EDITOR);
        iRichTextEditor->ConstructFromResourceL(reader);
    	CleanupStack::PopAndDestroy();
    	iRichTextEditor->SetRect(aRect);
    	iRichTextEditor->SetFocus(ETrue);
    	iRichTextEditor->SetCursorPosL(0,EFalse);
        // Create the scrollbar for the editor
        iScrollBarFrame = iRichTextEditor->CreateScrollBarFrameL();
        // Set horizontal scrollbar invisible (EOff) and vertical scrollbar
        // visible (EOn)
        iScrollBarFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
            CEikScrollBarFrame::EOn);
    	// [[[ begin generated region: do not modify [Post-ActivateL initializations]
    	// ]]] end generated region [Post-ActivateL initializations]
    	SetRect( aRect );
    	ActivateL();
    	LoadText();
    	}
    
    void CPengawasContainer3::LoadText()
    	{
    	_LIT(KBarisPertama, "Baris pertama\r\n");
    	_LIT(KBarisKedua, "Baris kedua\r\n");
    	_LIT(KBarisKetiga, "Baris ketiga\r\n");
    	_LIT(KBarisKeempat, "Baris keempat");
    	HBufC16* buf16 = HBufC16::NewL(100);
    	CleanupStack::PushL(buf16);
    	TPtr16 ptr(buf16->Des());
    	ptr.Copy(KBarisPertama);
    	ptr.Append(KBarisKedua);
    	ptr.Append(KBarisKetiga);
    	ptr.Append(KBarisKeempat);
    	iRichTextEditor->SetTextL(buf16);
    	//iRichTextEditor->HandleTextChangedL(); //using this doesn't help
    	CleanupStack::PopAndDestroy(buf16);
    	//iRichTextEditor->DrawNow();  //it doesn't help, either
    	/*TBuf<100> aTeks;
    	iRichTextEditor->GetText(aTeks);
    	iEikonEnv->InfoWinL(_L("Teks"), aTeks);*/
    	}
    How come the editor does not automatically display the text loaded into it? It does only when I hit the Left-Right arrow key. FYI, the editor is placed in a tabbed view.

    Your help to this "trivial" prob is greatly appreciated.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168

    Re: CEikRichTextEditor - SetTextL does not work!

    you could try calling DrawNow() after setting the text.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: CEikRichTextEditor - SetTextL does not work!

    thanks for your very prompt reply, yucca. however, as i indicated on the code above, it really doesn't work. the text shows up ONLY after i hit either the left or right arrow key (even on the device). please let me know which part i am missing or what i could've done wrong.

    as always, i raise my questions (two threads so far) on DiBo ONLY after i get really tired of browsing the search results and googling but end up finding no effective answers.
    Last edited by asepm; 2012-10-08 at 13:06.

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168

    Re: CEikRichTextEditor - SetTextL does not work!

    You are not calling DrawNow() after setting the text, so its unclear whether you did try it.. if not, please do.

    Also do check that the CCoeControl based container does return the internal controls(i.e. implement ComponentArrayExists() & ComponentControl(TInt)), including the editor when asked , otherwise the drawing will of course not work right.

    Also, you could try working with CRichText object of the editor.

  5. #5
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: CEikRichTextEditor - SetTextL does not work!

    dear, yucca. i commented out that "DrawNow()" part because it didn't work. and after i noticed your very prompt suggestion, i removed the comment and...it still didn't work. please help. i know you're a master, i've been using your Y-Tasks and Y-Browser on a daily basis. they really help with my personal project which has been around for 1 month.
    well, gotta try the CRichText (or CEikEdwin, if it supports multiline text) object anyway.
    Last edited by asepm; 2012-10-08 at 14:29.

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168

    Re: CEikRichTextEditor - SetTextL does not work!

    You could maybe check one of my old examples: http://www.developer.nokia.com/Commu...tor_in_Symbian it at least have worked just fine earlier.

  7. #7
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: CEikRichTextEditor - SetTextL does not work!

    Your code snippet could not compile which was only due to that undefined "StatusLineHeight" identifier, exactly as what was informed by someone else: "To use this example it is essential to know how StatusLineHeight is obtained. This is not shown in the example?". In addition, my tab view disappeared upon entering that particular view.
    To get rid of the glitch related to the "unknown" identifier , I replaced it with a constant and it worked like a charm (not really, actually). To add more lines, I removed the "iEditor->RichText()->Reset();" part. My question: how do I get my tab back when I'm in that view containing the editor? Another thing I will try to overcome myself is the order of the additional texts which are before the earlier ones.
    Sorry for the bother and thanks for your kind help so far. I'm a newbie, having leart Symbian for just one month or so now. I come from RAD programming tools such as Delphi (over 10 years) and VB... Not really great in those environments, though.
    Last edited by asepm; 2012-10-08 at 14:21.

  8. #8
    Nokia Developer Champion
    Join Date
    May 2004
    Posts
    2,267

    Re: CEikRichTextEditor - SetTextL does not work!

    Part of the wiki code snippet seems copied from the rich text editor example published by Nokia, check it out to know what exactly the StatusLineHeight is, and I suggest that you start from the working example.

    If you are using the Carbide.c++ UI Designer (In your code I see comments like "[[[ begin generated region:"), then another good way is to drag/drop a rich text editor from the pallette to your container, and then replace the SetTextL statement with your own.

    Either way is better than writing code from scratch.

    Just some wild guesses: will it be better if you switch LoadText(); and ActivateL(); ? or adding the EEikEdwinNoAutoSelection flag (avoid highlight issue)? If you don't have special requirement on the text format then maybe you can use CEikEdwin instead?

    BR/Ziteng

  9. #9
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: CEikRichTextEditor - SetTextL does not work!

    Debug and check what exactly you are passing to
    Code:
    iRichTextEditor->SetRect(aRect);
    in ConstructL and SizeChanged method.

Similar Threads

  1. There is no SetTextL(...) in CAknTextQueryDialog
    By Md. Kayesh in forum Symbian User Interface
    Replies: 4
    Last Post: 2011-07-20, 05:24
  2. SetTextL doesn't work!
    By asadi.alireza in forum Symbian User Interface
    Replies: 19
    Last Post: 2010-11-15, 12:43
  3. App close after SetTextL.
    By unidentify in forum Symbian User Interface
    Replies: 7
    Last Post: 2009-12-01, 07:05
  4. SetTextL() on target
    By yaront in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-01-24, 19:46
  5. SetTextL()
    By jesusdol in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-01-27, 18:44

Posting Permissions

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