stop bringing GUI to front

7 Ansichten (letzte 30 Tage)
Adrian
Adrian am 20 Sep. 2013
Hi,
I actually have 2 GUIs. One open in the front and another one running in the background. The GUI in the background shows an axes which displays a text that is rebuilt periodically. Every rebuild brings the GUI to front. How can I turn this off?

Akzeptierte Antwort

Jan
Jan am 20 Sep. 2013
A figure is moved to the front if it is explicitly requested to do so. Perhaps there is a figure(figHandle); axes(axesH) in your code, which move the figure to front and code to activate the wanted axes. Then text() writes to the specified axes, but the lifting of the figure is not useful in your case. A solution would be then:
text(0.5, 0.5, 'Hello', 'Parent', axesH)
Specifying the parent cares for writing to the wanted axes also, but without moving the figure to the front.
So please check your code e.g. by using the debugger until you find the command, which causes the activation of the figure. Then remove this command and replace it accordingly.

Weitere Antworten (1)

Sean de Wolski
Sean de Wolski am 20 Sep. 2013
Bearbeitet: Sean de Wolski am 20 Sep. 2013
Hi Adrian,
You have to use low level plotting functionality to set the properties of graphics objects (i.e. the text) that already exist rather than creating new ones.
I did this in an example here for changing the figure settings, you'll need to do the same for text.
If you want a small example, I could create it for you.
More: Example
function changeTextInBackground
%Some strings to cycle through
strings = {'Hello World';...
'Happy Friday';...
'Oktoberfest is nearly here';...
'The Patriots are still 2-0!';...
'And the Ravens aren''t.'};
%Background figure
hFig1 = figure;
set(hFig1,'units','normalized');
plot(1:10);
%We create the text box here, only once
hText = text(5,5,'Initializing...');
%Build the foreground figure
hFig2 = figure;
surf(peaks);
% Timer will change text every second
T = timer('Period',1,... %period
'ExecutionMode','fixedRate',... %{singleShot,fixedRate,fixedSpacing,fixedDelay}
'BusyMode','drop',... %{drop, error, queue}
'TasksToExecute',200,...
'StartDelay',0,...
'TimerFcn',@changeText,...
'StartFcn',[],...
'StopFcn',[],...
'ErrorFcn',[]);
ii = 0; %index for cycling through strings
start(T);
function changeText(~,~)
% increment location
ii = ii+1; %Move the figure
%This is the key line!!! hText already exists, we're just updating
%it
set(hText,'String',strings{ii});
drawnow; %force update
%Reset
if ii == numel(strings)
ii = 0;
end
end
end
  4 Kommentare
Adrian
Adrian am 20 Sep. 2013
I tried to set it invisible, it came back!
Adrian
Adrian am 20 Sep. 2013
But even if invisible would work, it would be a bad solution. Actually i am working with two desktops. If I am working with the one GUI I want to be able to take a look to the other one. But I dont want to lose focus periodically!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by