This forum is temporaily read-only. All existing discussions remain available for reference. For new questions, bug reports or support requests, please contact us at mail@lmdsupport.com.

Detect when a replace operation in SyntaxEdit is cancelled

When calling something like Edit->ReplaceAll(SA,rbAllText) for a replace with prompt operation, the user may be presented with a 'Replace this occurrence of XXX?' dialog with Yes, No, and Cancel options.

Is there a way for me to know when the user selected 'Cancel'?

Comments

  • edited September 2022
    There no way. And it seems useless, because replacing is a compound user workflow. The user can answer several times "Yes" and only after that - "Cancel". So, some modifications to the edit text will still be made in this case.

    Moreover, replacing can be continued by the user via pressing F3 even after "canceling" the dialog.
  • My use case is that I have a "replace in all open documents" function and it keeps moving to the next open document to repeat the search & replace operation, but if the user chooses cancel then I want to cancel the entire operation and not continue searching and replacing other documents. Without knowing that the user selected cancel, the program still moves on to the next document

    So if there is really no way to detect a cancel, then I don't think my program will be able to operate as expected when a user selects cancel when doing a 'replace in all open documents'.

    Anyway, my main point was to elaborate on my 'use case' because I do not think this feature/function would be useless.

    It's not a 'big deal' but it would be nice to address/fix if I could.

  • Ok, understood. This can be done. I'll look how to change code.
  • Hi,

    In addition to existing several SearchLastXxx properties I've created new SearchLastReplaceCanceled boolean property for you.
  • Great! Thank you.
  • So... minor issue/bug with SearchLastReplaceCanceled ...


    If I use LMDEditExecReplaceDialog(L"Replace in All Open Documents",Edit,LMDSearchDlgOptions) and the user chooses Cancel on the first 'Replace this occurrence' dialog, then Edit->SearchLastReplaceCanceled seems to be set to false when it should be set to true.

    It seems to work as long as it's not the first 'Replace this occurrence' dialog.

Sign In or Register to comment.