0

これは私の最初の質問です。だから.. これを下手に聞いたらごめんなさい。

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 は、実行するたびに色を切り替えません。元に戻す やり直しは引き続き機能します。

どんな助けでも大歓迎です、ありがとう:)

4

1 に答える 1

0

ええと...私はこれをさらに進めました。すべての操作を「editManager」クラスにパイプすることで、元に戻るやり直しの履歴が失われることはなくなりました。しかし...カラー化は元に戻せないアクションとしてカウントされるようになりました...ご想像のとおり、これは理想的ではありません。したがって、実際の取り消しと混合すると、構文の強調表示をすべて削除するものができます。まだそれを回避する方法を見つけようとしています。

現在の実装の要点は次のとおりです。

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);
于 2012-08-21T14:50:16.370 に答える