Insert character into text after caret position

Hi Clifton,
I'm trying to insert accented characters like é into an editable field. I can already do this using an embedded CKEditor pad which has an insertText function but now I need to do this using an ordinary TB field. The character must be inserted after the current caret position. The character is chosen from a small virtual keyboard which is part of my program.
I have thought of a possible solution:
Use caretPosition to determine where the user wants to put the character (usually at the end but it could be anywhere in the text) put chars 1 to caretPosition of the text into variable txt1 and chars caretPosition + 1 to charCount(text) into variable txt2 (but charCount() is not available I think so I would have to use the Javascript length property?) then redefine the text as txt1 + special character + txt 2 and reset the caretPosition to caretPosition + 1.
But this seems a bit complicated. Is there a better way, please?
UPDATE
Alternatively I could continue using the embedded CKEditor pad and convert the HTML code back to normal text using setHTMLContent. This might be simpler.
I'm trying to insert accented characters like é into an editable field. I can already do this using an embedded CKEditor pad which has an insertText function but now I need to do this using an ordinary TB field. The character must be inserted after the current caret position. The character is chosen from a small virtual keyboard which is part of my program.
I have thought of a possible solution:
Use caretPosition to determine where the user wants to put the character (usually at the end but it could be anywhere in the text) put chars 1 to caretPosition of the text into variable txt1 and chars caretPosition + 1 to charCount(text) into variable txt2 (but charCount() is not available I think so I would have to use the Javascript length property?) then redefine the text as txt1 + special character + txt 2 and reset the caretPosition to caretPosition + 1.
But this seems a bit complicated. Is there a better way, please?
UPDATE
Alternatively I could continue using the embedded CKEditor pad and convert the HTML code back to normal text using setHTMLContent. This might be simpler.