App Designer ListBox ValueChanged Callback with multiselect 'on'
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Suchitha Nama
el 6 de Abr. de 2022
Comentada: Suchitha Nama
el 7 de Abr. de 2022
I have 2 listboxes, one with a list of test number and another that is a list of run numbers. If I select a test number from the list box, I have a callback , TestListBoxValueChanged(app, event), that will display the corresponding run number for that specific test in the "Run" List box. This is working great when I only select one test, but I have multiselect on and when I try to select 2 or more tests, not all the run numbers show in the run listbox. I am using ctrl + click, or shift + click to select multiple test items from the list and I only see run numbers for the first clicked item.
I need help figuring out why the TestListBoxValueChanged callback is not working with multiple selections. Does the callback get triggered when multiple items are selected, including the original singly selected item?
function TestListBoxValueChanged(app, event)
% Get test numbers to index into dataset, convert to double.
selectedTest = str2double(app.TestListBox.Value);
selectedButton = app.TestDataSetButtonGroup.SelectedObject.Text;
if strcmp(selectedButton, "correctString")
datastruct = app.someData;
else
datastruct = app.otherData;
end
% Use array of double to index into data struct and get all of
% the runs for the test(s) selected.
runs = datastruct(selectedTest).runNumber;
% Update RunListBox
app.RunListBox.Items = string(runs);
end
0 comentarios
Respuesta aceptada
Voss
el 6 de Abr. de 2022
Try this (note the square brackets [ ]):
% Use array of double to index into data struct and get all of
% the runs for the test(s) selected.
runs = [datastruct(selectedTest).runNumber];
More information:
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!