Selection in HTML formatted input textfield
Hi,
To make a small text editor for a mailinglist front-end I have this code on a 'bold' button:
code:
on (rollOver) {
startSel = Selection.getBeginIndex();
endSel = Selection.getEndIndex();
oudeSelectie = Selection.getFocus();
if (endSel - startSel > 0) {
selected = "true";
} else {
selected = "false";
}
}
on (release) {
if (selected eq "true") {
Selection.setFocus(oudeSelectie);
Selection.setSelection(startSel,endSel);
beg = _root.ber.slice(0,startSel);
sel = _root.ber.slice(startSel,endSel);
end = _root.ber.slice(endSel,10000000);
_root.ber = beg + "<b>" + sel + "</b>" + end;
Selection.setSelection(0,0);
}
}
When my input textfield is not formatted with HTML it works perfectly. But I would really like to be able to have it work when HTML formatting is turned on too.
It seems to set the '< b >' and '< /b >' on the wrong place when the text is HTML formatted. It places it on the place where it should be when it's not HTML formatted; with other tags it completely messes everything up.
I have been busy with this for almost a week and can't figure it out :(
Any help would be so much appriciated!
:)
_____________
Vincent