Is it possible to allow a re-selection of the same option from a drop down menu?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a drop down menu that opens an additional app if its option is chosen. Once I return the the main app, I would like to choose the same option again from the drop down in order to view the entries I placed in the sub app. Is it possible to reselect the same option already chosen and open the new app? Matlab doesn't seem to allow me to choose an option again that's already been chosen.
1 Kommentar
Antworten (1)
Saffan
am 27 Jun. 2023
Hi Desmond,
I can understand that you want to re-select the same option from a drop-down menu. To allow re-selection of the same option, you can follow these steps:
- Create a default option in the drop-down menu with no actions, such as ‘Select’.
Here is an example code snippet to create a drop-down menu and value changed callback function:
% Create DropDown
app.DropDown = uidropdown(app.UIFigure);
app.DropDown.Items = {'Select', 'app1', 'app2'};
app.DropDown.DropDownOpeningFcn = createCallbackFcn(app, @dropDownOpen, true);
app.DropDown.ValueChangedFcn = createCallbackFcn(app, @valueChanged, true);
app.DropDown.BackgroundColor = [1 1 1];
app.DropDown.Position = [467 361 100 22];
app.DropDown.Value = 'Select';
% Value changed function: DropDown
function valueChanged(app, event)
value = app.DropDown.Value;
if (strcmp(value,'Selected'))
%do nothing
elseif(strcmp(value,'app1'))
%open app
app1;
end
end
- Reset the value to default option every time the drop-down menu is opened by using the drop-down opening callback function.
Here is an example code snippet of drop-down opening callback function:
% Drop down opening function:
function dropDownOpen(app, event)
app.DropDown.Value='Select';
end
Refer to this for more information:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!