Matlab App Designer Pop Up Figure

46 次查看(过去 30 天)
Currently I have a GUI edit field named Number of Segments where I can enter a number and a pop up window with tabgroups depending on the value for Number of Segment is inputted. Is there a way to add some sort of callback to the uieditfield of PropogationEdit or LoopsEdit? Also if I have multiple tabs how to differentiate the edit fields for each individual tab? If I can I want to store each tab as an array with the indexes being the edit field then an encompassing array storing each tab's array.
Thank you
Here is the code that I have for reference:
function NumberofsegmentsEditFieldValueChanged(app, event)
value = app.NumberofsegmentsEditField.Value;
app.UIFigure = uifigure("Position",[600 300 400 450]);
TabGroup = uitabgroup(app.UIFigure, "Position",[0 0 400 450]);
nTabs = value;
for i=1:nTabs
tab = uitab(TabGroup,"Title","Segment "+i);
%Propogation
PropogationTxt = uilabel(tab, "Text","Propogation Distance [m]","position",[100 350 150 20]);
PropogationEdit = uieditfield(tab,"numeric","position",[300 350 50 20])
%Loop
LoopTxt = uilabel(tab, "Text","Number of Loops","position",[100 300 150 20]);
LoopsEdit = uieditfield(tab,"numeric","position",[300 300 50 20]);
end
end

回答(1 个)

Eric Delgado
Eric Delgado 2022-11-18
You can use "Tag" property...
% Tabs creation
UIFigure = uifigure("Position",[600 300 400 450]);
TabGroup = uitabgroup(UIFigure, "Position",[0 0 400 450]);
for i=1:3
tab = uitab(TabGroup,"Title","Segment "+i);
PropogationTxt = uilabel(tab, "Text","Propogation Distance [m]","position",[100 350 150 20]);
PropogationEdit = uieditfield(tab,"numeric","position",[300 350 50 20]);
LoopTxt = uilabel(tab, "Text", "Number of Loops", "position", [100 300 150 20]);
LoopsEdit = uieditfield(tab, "numeric", "position", [300 300 50 20], "Tag", "Segment "+i);
end
% Edit Field search
hObj1 = findall(groot, 'Type', 'uinumericeditfield', 'Tag', 'Segment 1');
hObj2 = findall(groot, 'Type', 'uinumericeditfield', 'Tag', 'Segment 2');
hObj3 = findall(groot, 'Type', 'uinumericeditfield', 'Tag', 'Segment 3');

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by