Keyboard shortcut to quit kernel in Mathematica 5 and 7?

a 夏天 提交于 2019-12-07 22:46:47

问题


Here is an explanation how to define a custom keyboard shortcut for quitting the kernel of the selected notebook by modifying the file KeyEventTranslations.tr. This file is located by default (under Windows) for Mathematica 5.2 in the folder

C:\Program Files\Wolfram Research\Mathematica\5.2\SystemFiles\FrontEnd\TextResources\Windows

and for Mathematica 7.0.1 in the folder

C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\FrontEnd\TextResources\Windows

In this file after EventTranslations[{ I have added a line:

Item[KeyEvent["q", Modifiers -> {Control}],FrontEndExecute[FrontEndToken[SelectedNotebook[],"EvaluatorQuit",Automatic]]]

But unfortunately after restarting Mathematica the shortcut Control+q does not work on both versions.

Moreover, in Mathematica 7.0.1 executing the command

FrontEndExecute[FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]]

and pressing "Quit" leads to an application error and closing FrontEnd with loosing all unsaved changes (I am using Windows 2000).

What am I doing wrong?

EDIT: The problem was in missing comma after added Item[...] (thanks to belisarius). Here is the right line to add to KeyEventTranslations.tr:

Item[KeyEvent["q", Modifiers -> {Control}],FrontEndExecute[FrontEndToken[SelectedNotebook[],"EvaluatorQuit",Automatic]]],

Now shortcut Control+q works nice both in Mathematica 5.2 and 7.0.1. But the above bug with "application error" still appears (not when using the shortcut but only when evaluating FrontEndExecute[FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]] in notebook).


回答1:


This answer and the associated comments may help you.

HTH!

BTW ... I did the same in v7 and it worked. On what version are you having trouble?

Just a note: Be very careful with the syntax Verify that every Item[Keyevent ends with a comma, except the last one.



来源:https://stackoverflow.com/questions/4912754/keyboard-shortcut-to-quit-kernel-in-mathematica-5-and-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!