closing the figure window when pressing the mouse button on the X
2 次查看(过去 30 天)
显示 更早的评论
I have a GUI that runs for a few minutes. in this GUI I have images that are shown continuesly using the lines-
axes('Position',[.3 .25 .3 .5]);
image(imcell{1,2});
the problem is that even if I use my mouse to close the window by pressing the X in the left upper edge , there is a new window opened up showing those images until the end.
so how can I break the GUI from working (closing it) without getting a new window.
I guess its something like the "windowbuttonpressfcn" or "buttonpressfcn", but-
I dont think that pressing on the x is considered as a press becuase its outside the window.. I tried using the get(hobject,'currentpoint') but it didn't work and I think that's not the way..
I should mention that just preventing the new window to pop won't help me because I have also audio files that will keep on playing.
I need something that will r3ealy stop the entire procces , not only whats seen on the screen.
0 个评论
采纳的回答
Jan
2012-10-21
The CurrenPoint is not useful here.
Instead of creating new axes and images again and again, it would be more efficient to re-use the existing elements. And this would implicitly solve your problem also:
FigH = figure;
AxesH = axes('Position', [0.3, 0.25, 0.3, 0.5], 'Parent', FigH);
ImageH = [];
for ii = 1:1000
if ~ishandle(AxesH)
disp('Stopped by user');
return;
end
if isempty(ImageH)
ImageH = image(imcell{1,2}, 'Parent', AxesH);
else
set(ImageH, 'CData', imcell{1,2});
end
... Your code to create the new image here
end
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!