In my gui3 , i want to break loop when i close the gui figure window

4 ビュー (過去 30 日間)
cansu
cansu 2019 年 1 月 30 日
コメント済み: Jan 2019 年 1 月 30 日
I created closeRequestFunc with this code;
function figure1_CloseRequestFcn(hObject,eventdata,handles)
clear playsnd
delete(hObejct);
end
My for loop works. But i want to add if statement to break loop when closing figure window
i tried this but not work.
if (handles.figure1_CloseRequestFcn)
break;
end
What do you suggest ???
  1 件のコメント
Jan
Jan 2019 年 1 月 30 日
By the way: this is not twitter. No # before the tags, please.

サインインしてコメントする。

採用された回答

Rik
Rik 2019 年 1 月 30 日
You can write a small function that tests if the object still exists. Unfortunately, exist and isobject don't solve this for you.
if isdeleted(handles.figure1)
break;
end
function tf=isdeleted(h)
tf=false;
try
get(h);
catch ME
if strcmp(ME.identifier,'MATLAB:class:InvalidHandle')
tf=true;
end
end
end
  3 件のコメント
Rik
Rik 2019 年 1 月 30 日
@Adam, good point, didn't think about that function. You could also move that comment to an answers.
cansu
cansu 2019 年 1 月 30 日
@Rik ,Thanks a lot, it works!!

サインインしてコメントする。

その他の回答 (1 件)

Adam
Adam 2019 年 1 月 30 日
isgraphics( handles.figure1 )
will tell you if the figure is still active or has been deleted.

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by