Flex ApplyFormatOperation在Spark TextArea中中断撤消/重做

时间:2012-08-04 20:25:18

标签: flex textarea flex-spark

这是我在这里的第一个问题。所以..如果我问这个问题,我道歉。

我编写了一个突出显示文本编辑器的语法,扩展了Spark TextArea。 通过将ApplyFormatOperations应用于文本的各个不同部分,突出显示起作用。但是,只要我应用任何格式操作,我就会失去所有内置的撤消/重做功能。我关闭着色并撤消重做。

这是我正在做的一个简化版本,它消除了undo / redo。 想象一下,每当你输入一个角色时都会触发它。

//select everything
var operationState:SelectionState = new SelectionState(textFlow, 0, text.length);
//make an example format.
var exampleFormat:TextLayoutFormat = new TextLayoutFormat();
//everytime we run change the color of all the the text.
m_undoTest = !m_undoTest;
if (m_undoTest) {
    exampleFormat.color = "#0839ff"; //make all text bluish.
} else {
    exampleFormat.color = "#ff0839"; //make all text redish.
}
//make an operation to apply my formatting.     
var formatOperation:ApplyFormatOperation = new ApplyFormatOperation(operationState,            exampleFormat, null);
//apply the operation to the text area.
formatOperation.doOperation();

现在,当我输入时,我的文字从红色切换为蓝色,我无法撤消。有趣的是,如果我执行相同的步骤但不更改新格式的任何属性。 IE每次运行时都不会切换颜色。撤消重做仍然有效。

非常感谢任何帮助,谢谢:)

1 个答案:

答案 0 :(得分:0)

嗯......我通过“editManager”课程管理我的所有操作,我不再失去撤消重做历史了。但是......着色现在算作一种可撤销的动作......你可能想象的并不理想。所以,现在与你的实际undos混合,你有那些删除所有语法高亮。仍在试图找到解决方法。

当前实施的主旨是:

var editManager:IEditManager = textFlow.interactionManager as IEditManager;
//make an operation to apply my formatting.     
var formatOperation:ApplyFormatOperation = new ApplyFormatOperation(operationState,            exampleFormat, null);
//apply the operation to the text area.
editManager.doOperation(formatOperation);