I am trying to achieve the same behavior of delete (c) key press in my text editor programmatically. I could insert some characters such as ‘a’, ‘b’, ’c’ programmatically. Does anybody know how to do it?
Re: How to insert delete key in text editor (edwin) programmatic
You don't "insert a delete key", but you manipulate the content of the edwin in any way you like, e.g. deleting characters from it, and then put it back and ask the edwin to redraw. Here a rough sketch of a part of a program part that would do this:
Code:
 TBuf<200> str;  TInt len;  TInt cursorPos;  iEdWin->GetText(str);  len=str.Length();  cursorPos=iEdWin->CursorPos();  if (cursorPos>0) {   if (cursorPos==len) {    str.SetLength(len-1);   }   else {    str.Delete(cursorPos-1,1);   }   cursorPos--;   iEdWin->SetTextL(&str);    iEdWin->SetCursorPosL(cursorPos,EFalse);    iEdWin->DrawNow();  }
Re: How to insert delete key in text editor (edwin) programmatic
It is not going to help. I know how to do this kind of stuff. But my editor contains image and text both and for some reason, I have to delete 3 characters programmatically in some specific location of the editor. So I found only way to handle it, replace those 3 characters with empty space even though it does not look very good. It would be nice if I completely remove those characters. Thanks anyway!
Re: How to insert delete key in text editor (edwin) programmatic
Interersting.
So how do you replace the 3 characters with blanks?
If you have pictures as well I guess that rich text is in there someway. Did you already try to get the rich text object at the base of the editor and then work with CRichText::DeleteL?
Re: How to insert delete key in text editor (edwin) programmatic
I can delete text by using CRichText::DeleteL(). But it can't delete images from CEikRichTextEditor. I can delete images by using CEdwin::InsertDeleteCharsL(), which replace a range of characters by the given string. So I use this mehtod and pass parameters _L(" "), like this. So it will be nice if I could have any method to delete image and character at the same time and dont need to replace anything instead.
Re: How to insert delete key in text editor (edwin) programmatic
Well, so far I did not work with pictures in rich text. I checked the SDK documentation for the picture support in rich text now, and I must say that this is all somewhat confusing to me.
While browsing in the SDK help file I saw CRichText::DropPictureOwnership() which might or might not be able to delete pictures from a rich text, but as I said I did not try it myself, and the documentation is rather sparse...
Forum posts: 1242
 TInt len;
 TInt cursorPos;
 iEdWin->GetText(str);
 len=str.Length();
 cursorPos=iEdWin->CursorPos();
 if (cursorPos>0) {
  if (cursorPos==len) {
   str.SetLength(len-1);
  }
  else {
   str.Delete(cursorPos-1,1);
  }
  cursorPos--;
  iEdWin->SetTextL(&str);
   iEdWin->SetCursorPosL(cursorPos,EFalse);
   iEdWin->DrawNow();
 }
René Brunner
Forum posts: 68
Forum posts: 1242
So how do you replace the 3 characters with blanks?
If you have pictures as well I guess that rich text is in there someway. Did you already try to get the rich text object at the base of the editor and then work with CRichText::DeleteL?
René Brunner
Forum posts: 68
Forum posts: 1242
While browsing in the SDK help file I saw CRichText::DropPictureOwnership() which might or might not be able to delete pictures from a rich text, but as I said I did not try it myself, and the documentation is rather sparse...
René Brunner