How can i display a uicontrol object at different locations?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jonas Hemsen
el 10 de Nov. de 2017
Editada: Jonas Hemsen
el 23 de Nov. de 2017
Hi, I have a GUI with two tabs. On both tabs I want to display the identic edit field so that changes to one of the fields are always synched to both edit fields. Is this possible or unintended by the way GUI programming works?
If so, is there a clean workaround or any other ideas how I could achieve the feature?
Thanks and tell me if you need more specification of the problem. Jonas
2 comentarios
Geoff Hayes
el 10 de Nov. de 2017
Jonas - are you using GUIDE, App Designer, or are you programmatically creating the GUI?
Respuesta aceptada
Geoff Hayes
el 13 de Nov. de 2017
Hi Jonas - I suppose that you could assign the same callback to both edit controls. This callback would update a variable that could then be accessed by the other controls.
function sharedEditControl
hEdit1 = uicontrol('Style','Edit',...
'Callback', @EditControlCallback);
pos = get(hEdit1,'Position');
pos(2) = pos(2) + 100;
hEdit2 = uicontrol('Style','Edit',...
'Callback', @EditControlCallback, 'Position',pos);
sharedEditControlValue = [];
function EditControlCallback(hObject, eventdata)
sharedEditControlValue = get(hObject,'String');
fprintf('%s\n', sharedEditControlValue);
end
end
1 comentario
Jonas Hemsen
el 23 de Nov. de 2017
Editada: Jonas Hemsen
el 23 de Nov. de 2017
Más respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks 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!