Why is uilistbox Multiselect property being ignored inconsistently?

3 vues (au cours des 30 derniers jours)
Geoff
Geoff le 20 Avr 2016
Commenté : Greg le 23 Jan 2017
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 commentaires
Meade
Meade le 21 Avr 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
Greg le 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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by