how do I trigger the _OutputFcn output assignments and figure delete when I use a button to close a GUIDE GUI

Hello, I have a GUIDE GUI and I am trying to make an abort button which closes the GUI nicely and passes output variables to the functions that called the GUI.
I have seen people use delete(handles.figure1) to finish the GUI, but this does not seem to trigger the assignment of output variables (eg: varargout{1} = x does not happen).
I would really like my Abort button to trigger the execution of FunctionName_OutputFcn(...). If I try calling the output function from my abort button callback using "varargout = functionName_OutputFcn(hObject, eventdata, handles);", the callback, the figure closes and then opens again.
Anyone have any ideas?
Thanks, Ben

回答 (2 件)

Ben Ruppel
Ben Ruppel 2012 年 3 月 30 日
Okay, so it turns out that uiwait and uiresume are the answer. The GUIDE generated code comes with the commented out line: uiwait(handles.figure1). Because the figure is specified as the parameter, uiwait will resume as soon as delete(handles.figure1) happens. This made me think I could skip putting in uiresume in my buttons. However, when you execute delete(handles.figure1), the GUI is deleted before FunctionName_OutputFcn gets a chance to execute. The only way I know for the program to execute FunctionName_OutputFcn is for the GUI to "resume" via a uiresume call.
Sean de Wolski
Sean de Wolski 2012 年 3 月 30 日
You could uiresume() in the figure's deletefcn or closerequestfcn.

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

質問済み:

2012 年 3 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by