Borrar filtros
Borrar filtros

How to automatically update the value in a string in an edit box with a value in another edit box but still allow the user to overwrite this value?

2 visualizaciones (últimos 30 días)
I have a gui guide where I ask the user if it knows a value (number) in an edit box.
If the user knows this value I want the value in another edit box to automatically update. However, I want the user to be able to update/overwrite the value in the second edit box.
Any help is welcome. Thanks in advance.
  3 comentarios
Rik
Rik el 9 de Mzo. de 2023
Then it should be easy to generate the code and clean up the mess that GUIDE made, after which you no longer rely on a fragile system with two separate files, one of which easily breaks when edited in a wrong version of Matlab.
But the second part of my comment should still be worth a try regardless.

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 9 de Mzo. de 2023
Without GUIDE but a working demonstration:
handles.FigH = figure;
handles.Edit1 = uicontrol('Style', 'Edit', ...
'Units', 'Normalized', ...
'Position', [0.1, 0.55, 0.8, 0.4], ...
'Callback', @Edit1CB);
handles.Edit2 = uicontrol('Style', 'Edit', ...
'Units', 'Normalized', ...
'Position', [0.1, 0.05, 0.8, 0.4]);
guidata(handles.FigH, handles);
function Edit1CB(Edit1, EventData)
handles = guidata(Edit1);
set(handles.Edit2, 'String', get(Edit1, 'String'));
end
The callback of the first edit field copies its contents to the second one, but you can still edit the second one manually.
In your GUIDE code you omit the explicit guidata() calls. Insert the corresponding Callback to the first edit field.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by