Issue #
You are trying to capture the Save Edits and Stop Editing toolbar actions in ArcMap through code so that different actions can be performed for each event. Unfortunately the underlying events associated with the actions (saving and stopping editing) fire for both actions so figuring out if the use Saved or Stopped Editing is a chore.
Resolution #
Set up your code to listen for the events:
| |
Then put in whatever code you need to run on the Save Edits action. In this case there is no special code apart from the magic part where a boolean field is being set to true. This basically lets the application know that “I just did a save action”.
| |
With that field set to true, when the OnStopEditing event fires just afterwards, we can look at that field to see whether or not a Save just ran as well:
| |
Note that we are always setting the _isSavedAction field to false after any special code has run, and our special code only runs if the field is already false in the first place.
The Trick #
Turns out this approach works very well, but it does not capture edit events caused by background edits. By background edit I means something done in a cursor behind the scenes while an edit session is active, e.g., doing a little update cursor action in your own code while a regular ArcMap edit session is in progress. This is documented by ESRI but took me a while to figure out. Fortunately the answer is simple: force these kind of background, cursor driven events to fire like all the others:
| |