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

6 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 13 Avr 2023
Modifié(e) : MathWorks Support Team le 13 Avr 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:

Plus de réponses (0)

Catégories

En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by