Clear Filters
Clear Filters

What this actually means?????

2 views (last 30 days)
Santhosh
Santhosh on 2 Mar 2017
Commented: Santhosh on 2 Mar 2017
% Mygui('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in Mygui.M with the given input arguments.
How to use this??? Can this be used to call a sub function(namely a pushbutton) inside a gui from an external function which is a separate m file???

Accepted Answer

Walter Roberson
Walter Roberson on 2 Mar 2017
I guess you could use it that way. I would not do that myself.
It is mostly for internal use by GUIDE, due to the way it creates wrapper code around callback functions in order to be able to pass the handles structure into each callback.
If you do use it, make sure you pass the correct hObject and event structure required by the target callback.
A cleaner way is to move the code you need activated into a function in a location accessible from both files, and have both places make appropriate calls into the work routine.
  7 Comments
Walter Roberson
Walter Roberson on 2 Mar 2017
If you are using GUIDE, everything useful is within a callback, so you just pass that callback's copy of handles to the work_routine.
But if you just happen to have a different program from which you are invoking a GUIDE-created interface and you want to call the work routine from in there, then you first need to retrieve the handles structure. When you make an outside call to a GUIDE-created interface (by calling the function whose name is the GUI), then the routine returns the GUI figure handle as the return value. You would record that figure handle. From there,
handles = guidata(TheFigureHandle);
work_routine( handles );
Santhosh
Santhosh on 2 Mar 2017
Thanks Walter. I got it.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!