From: Chris Degnen on
Hi. Is it possible to run a command upon system close?

The 'close' menu binding is customisable but doesn't seem to accept a
sequence of tokens, e.g. Item["E&xit",
KernelExecute[CustomFunction[]]; "FrontEndQuit"]

The top-right close button isn't affected by the menu binding though.

Thanks in advance.

From: Szabolcs Horvát on
On 2010.02.10. 9:36, Chris Degnen wrote:
> Hi. Is it possible to run a command upon system close?
>
> The 'close' menu binding is customisable but doesn't seem to accept a
> sequence of tokens, e.g. Item["E&xit",
> KernelExecute[CustomFunction[]]; "FrontEndQuit"]
>
> The top-right close button isn't affected by the menu binding though.
>

$Epilog is evaluated on kernel quit. I don't think there is anything
similar for the front end quit.

From: Chris Degnen on
Thanks.

Actually I got most of the way there. I just added

FrontEndExecute[FrontEndToken["FrontEndQuit"]];

to the end of the function I wanted to run, then added
a menu bar item to run the function. E.g. to

....\SystemFiles\FrontEnd\TextResources\Windows\MenuSetup.tr

I added:

Item["Exit",
KernelExecute[Get["CustomFunction`"]], MenuEvaluator->Automatic]

I would like to place the menu item over on the right, under the
window-close button on the frame.

I tried Alignment->Right but it won't budge. Any suggestions?


Szabolcs Horv=E1t wrote:
> Chris Degnen wrote:
>
> > Hi. Is it possible to run a command upon system close?
>
> > The 'close' menu binding is customisable but doesn't seem to
> > accept a sequence of tokens, e.g. Item["E&xit",
> > KernelExecute[CustomFunction[]]; "FrontEndQuit"]
>
> > The top-right close button isn't affected by the menu binding though.
>
> $Epilog is evaluated on kernel quit. I don't think there is anything
> similar for the front end quit.