Filter löschen
Filter löschen

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 Ansichten (letzte 30 Tage)
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 Kommentare
Rik
Rik am 9 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 9 Mär. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by