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
ToggleMenuItem? I just saw it in theComponentwiseContextMenuand it seems potentially useful if I ever make an application with a custom menu on one of its boxes. – b3m2a1 Dec 20 '17 at 08:08ToggleMenuItemthis I didn't know. Would be nice to get feedback from WRI about the future of such findings. I don't like to use too deep stuff as I usually need it to work on win/mac/player/future versions. – Kuba Dec 20 '17 at 09:01