禁止 Matlab 窗口焦点窃取 [英] Inhibit Matlab Window Focus Stealing

查看:33
本文介绍了禁止 Matlab 窗口焦点窃取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法告诉 Matlab 不要根据 figureplot 等图形命令窃取窗口焦点(来自外部编辑器,例如 Emacs).这将大大提高我的工作效率,因为我经常希望在数据(重新)处理期间继续代码开发.

解决方案

是有可能的,诀窍是不使用 figure 语句,而是直接更改当前图形.这将改变活动图而不改变焦点.通常我会这样做:

函数 change_current_figure(h)set(0,'CurrentFigure',h)

那么,所有的figure(h)语句都需要改成change_curent_figure(h).

请注意,这包含在 matlab 文档中. >

应该注意,这仅在图形已经创建时才有效.如果要定期创建新图形,可以将图形创建为最开始的几行代码,保存句柄,进行处理,然后绘制它们.这个例子会起作用.请注意,drawow 命令将刷新事件缓冲区,确保绘制所有图形.

我从 2007 年到 2010 年看过这项工作,不确定最新或更早的版本是否支持这一点,尽管我没有理由怀疑他们不支持.

fig1=figure;图2=图;绘制;[a b]=do_complex_processing;change_current_figure(fig1)情节(一);change_current_figure(fig2)情节(b);

Is there a way to tell Matlab not to steal window focus (from an external editor) such as Emacs) upon graphical commands such as figure and plot. This would increase my productivity a lot because I often want to continue code development during data (re-)processing.

解决方案

It is possible, the trick is to not use the figure statement, but to change the current figure directly. This will change the active plot without changing the focus. Typically I do something like this:

function change_current_figure(h)
set(0,'CurrentFigure',h)

Then, all of the figure(h) statements need to be changed to change_curent_figure(h).

Note, this is included in the matlab documentation.

It should be noted, this only works if the figure is already created. If new figures are going to be periodically created, one could create the figures as the very first few lines of code, save the handles, do the processing, and then plot to them. This example would work. Note, the drawnow command will flush the event buffer, making sure all figures are plotted.

I've seen this work from 2007-2010, not sure if the latest or earlier versions support this, although I have no reason to suspect they don't.

fig1=figure;
fig2=figure;
drawnow;
[a b]=do_complex_processing;
change_current_figure(fig1)
plot(a);
change_current_figure(fig2)
plot(b);

这篇关于禁止 Matlab 窗口焦点窃取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆