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

7 次查看(过去 30 天)
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?

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2023-4-13
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:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

标签

尚未输入任何标签。

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by