Initial value in uihtml + Javascript implementation of text input

2 vues (au cours des 30 derniers jours)
David Aronstein
David Aronstein le 11 Oct 2021
Since I got extremely helpful input on a previous question on this same general theme:
I thought I'd turn to you amazing people again.
In the attached .mlapp and .html files, the app simply asks for input in the top box and echos whatever is entered there in the bottom box. Nice and simple.
What I'd like to do is have an initial value appear in this box, sent over from MATLAB. In this code, I am trying two things out:
1) I try entering one string in the startupFcn, line 17
2) I try entering another string in the initial definition of the uihtml widget, line 53.
Neither string appears when the app is run.
When input is received in the app and is recorded in the bottom box, it simply echos to the screen (when run inside MATLAB) the state of the "event" variable. That shows that app.HTML.Data was correctly set in startupFcn, line 17, but that value is not being sent over to the Javascript or not triggering the DataChanged listener in the Javascript code.
The process of updating the text that appears in the upper box, using app.HTML.Data = ... works just fine elsewhere in the MATLAB code, like in line 29.
So it seems that a listener, either on the MATLAB or on the Javascript side, is not up and running when the app's startupFcn executes. Is there a way to set an initial value in the uihtml text edit box in the startupFcn, or at least before the app has started and is waiting for user input?
  3 commentaires
David Aronstein
David Aronstein le 13 Oct 2021
Modifié(e) : David Aronstein le 13 Oct 2021
Thank you, Antonio! Adding the drawnow command does make the "startupFcn test!" text to appear in the top text box, in MATLAB 2020a. Fantastic!
You helped so much with my last question, too... I think I should just direct my questions straight to you in the future... :)
David Aronstein
David Aronstein le 13 Oct 2021
On a mundane note, your reply shows up as a "Comment" instead of an "Answer" and I'm not sure how to mark it as the accepted answer? I will certainly give you "credit" for it if I am able.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by