Excecute App Designer ValueChangeFcn Callback function programmitically

8 visualizzazioni (ultimi 30 giorni)
Hello fellow members, Previously I have made several GUIs programmatically with GUIDE components. Recently I am developing the GUI using App designer Components. In GUIDE components, it was easy to execute callback functions programmatically.I am trying the same method for App Designer components but it is not working.
I have one uiedittext field, I have changed its value programmitically and now I want to execute its callback function aka ValueChangedFcn, but I haven't able to figure out the way to mimic it.
I would be very thankful if anybody can help me in this matter. FYI I am using MATLAB 2017a

Risposte (1)

Jibran Shahid
Jibran Shahid il 8 Gen 2018
Hello again fellow members, well after playing for an hour. I finally figured it out, but instead of deleting the question. I thought why not just post an answer. So here is my solution.
txt = uieditfield(fig,...
'Position',[100 175 100 22],...
'tag','texteditField',...
'ValueChangedFcn',@(txt,event) textChanged(txt,lbl));
end
% Code the callback function.
function textChanged(txt,lbl)
lbl.Text = txt.Value;
end
In the above code, if I want to find this graphical object from any other funtion then I can use findobj with the current figure as a first argument of findobj.
Txt = findobj(figure,'tag','texteditField')
TxtCallback = Txt.ValueChangedFcn;
TxtCallback(Txt);
Thank you

Categorie

Scopri di più su Creating, Deleting, and Querying Graphics Objects in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by