Initial value in uihtml + Javascript implementation of text input

2 visualizaciones (últimos 30 días)
David Aronstein
David Aronstein el 11 de Oct. de 2021
Editada: David Aronstein el 13 de Oct. de 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 comentarios
David Aronstein
David Aronstein el 13 de Oct. de 2021
Editada: David Aronstein el 13 de Oct. de 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 el 13 de Oct. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by