2012-08-04 25 views
0

這是我在這裏的第一個問題。所以..如果我問這個不好,我很抱歉。Flex ApplyFormatOperation在Spark TextArea中取消/重做

我已經寫了一個語法高亮的文本編輯器來擴展Spark TextArea。 突出顯示通過將ApplyFormatOperations應用於文本的各個不同部分而起作用。但是,只要我應用任何格式操作,就會失去所有內置的撤銷/重做功能。我關閉着色並撤銷重做。

下面是我正在做的一個簡化版本,用於清除撤銷/重做。想象一下,每當你輸入一個角色時,都會觸發它。

//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每次運行時都不會切換顏色。撤消重做仍然有效。

任何幫助將不勝感激,謝謝:)

回答

0

嗯...我還得到了這一點,通過了「在EditManager」級管道我所有的操作我不會再失去撤銷重做歷史。但是......色彩現在被認爲是一種可撤銷的行爲......正如你可能想象的那樣,它並不理想。所以,現在與您的實際undos混合,你有刪除所有語法突出顯示。仍試圖找出解決辦法。

目前執行的JIST是這樣的:

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