DeleteMarkedCharInAllPar and Undo

  • Hi!

    I have som special text objects that can only be deleted in pairs so if a user presses delete before an object I have to look for the other object. When I find them I mark them with the afsDelete flag and then executes the DeleteMarkedCharInAllPar method and my two objects disappears.

    But if the user wants to undo this action and presses Ctrl+Z I get some problem. If the objects are located in the same paragraph they both appear at the same time (one Ctrl+Z), this is good. If the objects are located in different paragraphs, only one object appears at the first undo action. The user has to press Ctrl+Z one more time to restore the second object, this is not good.

    How can I get both my objects to be restored with one undo action regardless if they are located in one or two paragraphs?

  • I found some methods in TWPUndoStack that maybe is what I'm looking for, but I can't find any documentation about this class.

    If I do this it seems to be working the way I want it to work:

    Code
    WPRichText.Memo.UndoStack.StartUndoLevel;
    WPRichText.DeleteMarkedCharInAllPar();
    WPRichText.Memo.UndoStack.EndUndoLevel;

    Is this the right way to do it?

    • Offizieller Beitrag

    The function DeleteMarkedCharInAllPar does nor care about UNDO.

    You need to save one copy of the text before the call:

    WPRichText1.Memo.UndoStreamStart(wputDeleteText);
    WPRichText.DeleteMarkedCharInAllPar();
    WPRichText1.Memo.End;

    Julian