Borrar filtros
Borrar filtros

Execute callback between different GUIs

1 visualización (últimos 30 días)
fjnb86
fjnb86 el 12 de En. de 2012
Hello everybody!
Easy question (I think)
I have two GUIs with its own buttons:
GUI_A GUI_B
I want to execute a callback in B and at then, execute the other callback in A.
Code example in GUI_B:
%
button_GUIB_callback(hObject, eventdata, handles)
code
guidata(hObject, handles);
if GUI_A still open
???execution of button_GUIA_callback
close(GUI_B)
else
msgbox('you closed the other window dude!' )
end
I was looking for the answer but I can not find exactly what I want or if is possible.
Thanks in advance

Respuesta aceptada

fjnb86
fjnb86 el 16 de Mzo. de 2012
Hi David,
I solved going to the properties in the GUI that I have in the background (A), clicking in the properties of this button that I want to execute.
There is a code which appears in the field Callback
Finally I put this code in the button of GUI B, and works!
GUI_A('pushbutton1_Callback',gcbo,[],guidata(gcbo))
close %close GUI_B
Of course I must use "getappdata" and "setappdata2 to move the data between GUIs
:D

Más respuestas (2)

David
David el 12 de En. de 2012
Pass the handle to gui A into the init of gui B and then check the status of A in B.
e.g.
h = guiA;
guiB(h);
in the guiB init code you can add h to your handles -> Robert is your mothers brother.
N.B. ensure that GUIA is written such that it returns the relevant handle.
  2 comentarios
fjnb86
fjnb86 el 12 de En. de 2012
Hi David, thanks
If I follow your instructions when I pass the handle A to my B, A "restarts" and I am no interested in that because loads some code that I put there.
Is it the only way?
David
David el 12 de En. de 2012
Sorry I didn't really answer your question there (I was looking at the checking of GUI being open bit, rather than the question you were asking about the visibility of GUIA callback). See my next attempt for providing your answer.

Iniciar sesión para comentar.


David
David el 12 de En. de 2012
Sorry misread what you want. Try making the callback function a separate function in its own m-script and then ensure that you pass the correct data into your callback. e.g. have guiA.m, guiB.m and guiBtnCallBack.m which contains a fcn
function guiBtnCallBack(hObj, evtData, handles)
Ensuring that gui B has sufficient data passed into it for calling this callback, then both A and B can call it.

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by