|
-
Senior Member
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
-
Senior Member
Sorry to bumb this 
Is this impossible or do I need to go another way?
I have seen examples online I have no clue how to do it though. The selection thing works but I can't seem to get it to work when the textfield is HTML formatted...
Any help, please?
Vincent
SWIS BV
Last edited by Markp.com on 07-23-2003 at 02:25 AM
-
like this ?
So you want something like this:
http://www.myrichtext.com
Im not trying to sell you something, don't worry. The bad news is that you are way off, you don't want to specifically write the tags, let Flash do it for you.
Step 1:
It seems you have a decent grasp on getbeginIndex, you need to check out getTextFormat, getNewTextFormat, setNewTextFormat, and setTextFormat.
They let you do things like myFormat = mytextfield.getTextFormat
if (myFormat.bold) {
newFormat.bold = false;
mytextfield.setTextFormat(newFormat)
} else {
newFormat.bold = true;
mytextfield.setTextFormat(newFormat)
}
-
Senior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|