Why is uilistbox Multiselect property being ignored inconsistently?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am using the new App Designer in 2016a and have created a uilistbox. The Multiselect property is set to 'on'. When running with a debug flag set multi-selection works, when running normally multi-selection does not work. What is driving this behavior? Are there any workarounds or solutions?
Auto generated code that creates the list box:
app.DaysimeterList = uilistbox(app.HomeTab);
app.DaysimeterList.Items = {'proto 1', 'proto 2'};
app.DaysimeterList.Multiselect = 'on';
app.DaysimeterList.ValueChangedFcn = createCallbackFcn(app, @DaysimeterListValueChanged);
app.DaysimeterList.Position = [526 83 100 299];
app.DaysimeterList.Value = {'proto 1'};
Code that updates the list and is supposed to select all items:
function results = refreshDaysimeterList(app)
daysimeterPaths = app.getDaysimeters;
deviceSns = cellfun(@app.getDeviceSn,daysimeterPaths,'UniformOutput',false);
app.DaysimeterList.Items = deviceSns';
app.DaysimeterList.ItemsData = daysimeterPaths';
if isempty(daysimeterPaths)
app.DaysimeterList.Enable = 'off';
app.DaysimeterList.Items = {'None'; 'detected'};
else
app.DaysimeterList.Enable = 'on';
app.DaysimeterList.Value = app.DaysimeterList.ItemsData(:); % Select all Daysimeters
end
end
The update function is called during the App startup:
% Code that executes after component creation
function startupFcn(app)
app.loadPreferences; % Load the App preferences
app.refreshDaysimeterList; % Refresh the Daysimeter list
end
3 Kommentare
Meade
am 21 Apr. 2016
The "Value" method is usually indices, but you're trying to assign it whatever format "ItemsData" is in.
Try changing the last line in your refreshDaysimeterList fnc.
app.DaysimeterList.Value = 1:numel(app.DaysimeterList.ItemsData); % Select all Daysimeters
Does this change your result?
Greg
am 23 Jan. 2017
The comment by Meade is completely off the mark. AppDesigner documentation clearly states that the 'Value' property is a value of the 'ItemsData' property, or of 'Items' if 'ItemsData' is empty.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!