Disabling Ctrl+C in a GUI
9 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
is there a way to disable Ctrl+C when no edit text or similar has focus, to prevent it crashing a GUI?
Thanks
0 个评论
采纳的回答
Walter Roberson
2012-1-3
No, there is not. control-c cannot be disabled in MATLAB.
4 个评论
Walter Roberson
2012-1-3
http://www.mathworks.com/matlabcentral/newsreader/view_thread/246784
"No. In older releases, Ctrl-C could be caught by TRY/CATCH; that changed a while ago. [When Ctrl-C was caught, you could get into a situation where there was no way, short of terminating the MATLAB process, to end your code.]"
That thread is still not quite authoritative with regards to compiled executables,
Unfortunate that Windows uses control-c for "paste".
更多回答(1 个)
Sean de Wolski
2012-1-3
Although there's no way to disable it, you can keep stuff running even if it is called using a timer to execute your tasks.
Example:
t = timer('timerfcn','disp(''hello world'')','period',2,'taskstoexecute',10,'executionmode','fixedrate');
start(t)
It is going to display hello world 10x and if you click crtl+c in the middle the remaining hello worlds will still be displayed.
And what do you mean by GUI crashing?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!