Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

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'?


  • 8 Comments sorted by Votes Date Added
  • edited September 2022 Posts: 0Vote Up0Vote Down
    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.
  • OK, thank you.
  • 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.

  • Posts: 0 Accepted Answer Vote Up0Vote Down
Sign In or Register to comment.