selection problem with CEikRichTextEditor

Login to reply to this topic.
Tue, 2005-03-22 13:07
Joined: 2004-02-04
Forum posts: 8
I've got a selection problem with CEikRichTextEditor.

It seems the first time this container control is created and foregrounded, the entire CEikRichTextEditor is selected.

Nothing I do programmatically (e.g. ClearSelectionL) seems to clear the selection.

The selection goes away as soon as I move the cursor by hand, or if I background and the foreground the container.

Code:
MyContainer::ConstructL()
{
CreateWindowL();

// Create CEikRichTextEditor
iBody = new (ELeave) CMultipleControlEdwin;
iBody->ConstructL(this,0,0,0);

SetRect(aRect);

iBody->SetFocus(ETrue);
iBody->SetWordWrapL(ETrue);
iBody->SetReadOnly(ETrue);

ActivateL();
}


Then, at some point later when text becomes available for the object, but in practice immediately after ConstructL above:

Code:
MyContainer::SetText()
{
const TDesC8 & body = GetTextL();
HBufC * bodyBuf = HBufC::NewLC(body.Size());
TPtr bodyPtr = bodyBuf->Des();
bodyPtr.Copy(body);

// Be sure to set cursor and clear selection before
// setting text with new values or you'll get an ETEXT 12 panic.
iBody->SetCursorPosL(0,EFalse);
iBody->ClearSelectionL();

iBody->SetTextL(&(*bodyBuf));
iBody->ClearSelectionL();

DrawNow();

CleanupStack::PopAndDestroy(bodyBuf);
}

Michael Maguire


Thu, 2005-05-19 22:39
Joined: 2005-01-12
Forum posts: 8
Re: selection problem with CEikRichTextEditor
I had a similar problem when I inserted text from a file into an EDWIN in a dialog.  The solution was to specifiy the no auto selection in the "flags" attribute in the resource file as:


RESOURCE DIALOG r_help_dialog
{
  flags   = EEikDialogFlagFillScreen | EEikDialogFlagWait | EEikDialogFlagNoDrag;
  title   = STRING_r_help_title;
  buttons = R_EIK_BUTTONS_OK;
  items =
  {
   DLG_LINE
   {
      id = EHelpDialogEdwin0;
      type = EEikCtEdwin;
      control = EDWIN
      {
         flags = EEikEdwinNoAutoSelection | EEikEdwinReadOnly;    // <-- add this
      };
   }
  };

Attempting to do the equivalent via:

editor->SetCursorPosL(0, EFalse);
editor->SetSelectionL(0, 0);
editor->SetNonFocusing();
editor->SetReadOnly(ETrue);

etc. had no effect in the code.
  • Login to reply to this topic.