How do I stop the formatting (bold etc) being lost when a user deletes a whole line in Flex tlf textflow control
I am using text layout framework textflow in Flex 3 to get embedded images. In the edit field for the application the user can apply formatting. This all works fine except if the user deletes all the text they have entered and then starts typing again then the formatting is lost.
I'm using
//setup default formatting
currentCF.fontWeight = FontWeight.NORMAL;
_currentCF.fontStyle = FontPosture.NORMAL;
_currentCF.textDecoration = TextDecoration.NONE;
_currentCF.color = 0; //black
IEditManager(textFlow.interactionManager).applyLeafFormat(_currentCF);
To setup the initial formatting then similar code to apply the formatting when the user changes it.
So how can I stop the user from 'deleting'开发者_如何转开发 the formatting if they delete all the text?
Thanks, Nigel
OK. Not sure what is going on with the span elements that allows the formatting to be deleted. But I've worked around it by capturing the backspace\delete keys and setting the current formatting onto the textflow and this has worked around it.
protected function onKeyUp(event:KeyboardEvent):void
{
//check if backspacing or deleting
if (event.keyCode == 8 || event.keyCode == 46)
{
//check if they have removed all text which can lose the formatting
if (textFlow.textLength == 1)
{
//apply the current formatting
editMan.selectAll();
IEditManager(textFlow.interactionManager).applyLeafFormat(_currentCF);
}
}
}
精彩评论