GUI guide edit box
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (1)
Walter Roberson
el 23 de Mzo. de 2016
2 comentarios
Walter Roberson
el 23 de Mzo. de 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.
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!