필터 지우기
필터 지우기

App Designer : Text field making visible and invisible when select and re-select same option from drop down menu

조회 수: 3 (최근 30일)
I am trying to make a text field visble when I select an option form the drop down and when I re-select that option, I want to make that text field hide. Please suggest me how to do this using drop dwon.

채택된 답변

Mario Malic
Mario Malic 2020년 9월 13일
편집: Mario Malic 2020년 9월 13일
You can create a property called
Last_Selection = '';
In the DropDownMenu callback
function DropDownValueChanged(app,event)
if isempty(app.Last_Selection)
app.Last_Selection = app.DropDownMenu.Value % Initialises Last_Selection on first callback
else
if isequal(app.Last_Selection, app.DropDownMenu.Value)
% Hide something
% I am not sure how it goes with hiding/removing dropdown values
% First you have to assign to some other dropdown value and then remove it
% if you don't want errors
% ind = find (app.DropDownMenu.Value == app.DropDownMenu.Items); % get index of data to be removed
% app.DropDownMenu.Value = change_to_other_value
% app.DropDownMenu.Items{1,ind} = ''; % Test if it actually works
else
app.Last_Selection = app.DropDownMenu.Value
end
end
end
The question is, does the callback gets executed if the DropDownMenu.Value stays the same?
It might be more intuitive to the user what to do to remove the dropdown value, by adding the button instead.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by