PDA

View Full Version : Insert text (or string) in RTF object


yosik
01-29-2008, 04:41 AM
Is the above possible?
I tried working via the clipboard but could not find a way to copy a string into the clipboard.
I tried working with GetSelection but it only gives the position (start and end) of the selection, not the text itself.
What I need is actually to insert text before and after a line in a html file.

My scenario was to read the html file into a RTF object, thus allowing the user to highlight the relevant line. Then I wanted to put some text before and after that line. Something like:

Starting with:
yadayadayada

and ending with:
intro text yadayadayada outro text

Any idea?

Thanks

Yossi

Worm
01-29-2008, 06:50 AM
Maybe something like this?

tPoint = RichText.GetSelection("RichText1")
sLeft = String.Left(RichText.GetText("RichText1", false), tPoint.Start -1)
sSelected = String.Mid(RichText.GetText("RichText1", false), tPoint.Start, tPoint.End - tPoint.Start + 1)
sRight = String.Mid(RichText.GetText("RichText1", false), tPoint.End + 1, -1)

Dialog.Message("", sLeft.." Intro "..sSelected.." Outro "..sRight)

yosik
01-29-2008, 10:08 PM
YES! Exactly.
Thank you Worm. Should have solved that myself but I was stuck in brain-mud.
:yes:yes:yes

Yossi