How to execute the callback of an editable text field in my GUIDE application from the Command Window?

7 views (last 30 days)
I have created a GUIDE figure that contains an edit box, and then I have assigned a callback function to that edit box that executes whenever the user enters a new string into the edit box.
However, I have the need to call this callback from outside the figure (e.g. the command line) as if it's being executed by the edit box itself. I need to do this so that I can trigger some functionality that is very specific to that callback and the UI object and figure to which it's attached.
My callback function looks like this:
edit1_Callback(hObject, eventdata, handles) 
How can I call this callback function from the command line or from anywhere else?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Apr 2023
Edited: MathWorks Support Team on 13 Apr 2023
Here is example code that outlines one approach to do this.  For illustration purposes, I am assuming that your GUIDE application is called "myGUI".
h = myGUI;
handles = guidata(h); %The "guidata" function is used to retrieve the "handles" structure from the figure or any of its components.
hObject = handles.edit1; %This assumes that your edit box has its object "Tag" property set as "edit1". Please revise as needed.
eventdata = []; %If your callback does not specifically need/use "eventdata", then you can supply an empty array.
myGUI('edit1_Callback',hObject,eventdata,handles) %This line of code is used to call "edit1_callback" and provide it the relevant input arguments.
For your reference, here are two relevant links from the documentation:

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!