So I found the answer to this in an old answer of mine. The trick is to use the undocumented EvaluationOrder
.
By assigning EvaluationOrder->After
our event gets called after the built-in one. To test this we can try the following. First, see what happens with "ModifiedInMemory"
with the explicit order we started with:
SetOptions[
EvaluationNotebook[],
NotebookEventActions ->
{
{"MenuCommand", "Save"} :>
(
NotebookSave[];
Print[Lookup[NotebookInformation[], "ModifiedInMemory"]]
)
}
]
(* prints False on save events *)
With no EvaluationOrder
:
SetOptions[
EvaluationNotebook[],
NotebookEventActions ->
{
{"MenuCommand", "Save"} :>
(
Print[Lookup[NotebookInformation[], "ModifiedInMemory"]]
),
PassEventsDown -> True
}
]
(* prints True on save events *)
With no EvaluationOrder->After
:
SetOptions[
EvaluationNotebook[],
NotebookEventActions ->
{
{"MenuCommand", "Save"} :>
(
Print[Lookup[NotebookInformation[], "ModifiedInMemory"]]
),
PassEventsDown -> True,
EvaluationOrder->After
}
]
(* prints False on save events *)
This also works for EventHandler
and CellEventActions