Flex ApplyFormatOperation中断Spark TextArea中的Undo/Redo



这是我在这里的第一个问题。所以…如果我问得不好,我道歉。

我已经编写了一个语法高亮显示的文本编辑器,它扩展了sparkTextArea。高亮显示的工作原理是将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不会在每次运行时切换颜色。撤消重做仍然有效。

如有任何帮助,我们将不胜感激:)

嗯。。。我更进一步,通过将所有操作通过"editManager"类,我不再丢失撤消重做历史记录。但是着色现在被视为不可撤消的操作。。。正如你可能想象的那样,这并不理想。因此,现在与实际的undo混合在一起,就可以删除所有语法高亮显示。还在想办法解决这个问题。

当前实现的要点是:

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);

最新更新