Effacer les filtres
Effacer les filtres

GUI guide edit box

3 vues (au cours des 30 derniers jours)
Jovos
Jovos le 23 Mar 2016
Commenté : Walter Roberson le 23 Mar 2016
Hi, I am making a simple GUI calculator. My question is after I set up the edit box. For example:
amount = uicontrol('Style','edit','String',' ',...
'Position',[35,30,60,15],...
'Callback',{@amount_Callback});
I can type in numbers/characters there. I wonder how can I store those numbers into a variable. So that I can used them in the callback function.
Additionally, I am a bit confused how the call back function works. Say if I need that value of amount(defined above) as a variable, do I just define a new variable such as x = something?
Any information is helpful. A simple example will be great. Thank you.

Réponses (1)

Walter Roberson
Walter Roberson le 23 Mar 2016
  2 commentaires
Jovos
Jovos le 23 Mar 2016
Can you be more specific?
Walter Roberson
Walter Roberson le 23 Mar 2016
Inside the callback function, get() the String property of the uicontrol. You can store it in a variable. You will likely want to make the value available outside of the workspace of the callback function. Use one of the techniques described in the above link to make the value available outside of the workspace.
Note: Most commonly, callback functions for edit controls are mostly used to validate that the string is an acceptable answer, such as making sure that it looks like a number. Usually each routine that wants to use the string retrieves the String property of the control. However, this is by no means universal, and it is entirely valid to have the edit callback interpret the value and store it in a location for other values to retrieve; doing so has some advantages.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by