How to execute the callback of an editable text field in my GUIDE application from the Command Window?
7 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2019-2-11
编辑: MathWorks Support Team
2023-4-13
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
2023-4-13
编辑: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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!