PDA

View Full Version : Replace selected text in Input



markstaylor
10-11-2009, 01:56 AM
Having trouble....

Trying to have a button to add "<b>" in the beginning and "<\b>" at the end of selected text inside an input box. not all the text inside just what is selected. Just like if you were to make BOLD bold by selecting the button in this message box.

RizlaUK
10-11-2009, 04:25 AM
its not as simple as you would have thought, i did this for my BBCoder way back, inserting the tags, i rewrote the system 3 times

search the forum for worms 'caret' dll, you will need it to get precise positions on the cursor, then when adding the text you calculate how much text was added from the start point + 3 (for <b>) and the endpoint (new string length - 4 for </b>) and set the selection to the result (text that was added)

its tricky to get right

take a look at my app, i no longer have the source but i would be willing to write the system for you, do you have finance ?

BBCoder v3 (http://www.softpedia.com/get/Internet/Other-Internet-Related/BBCoder.shtml)