No item can be selected when having a single element in a list box (App Designer)

2 views (last 30 days)
Hello,
I am doing a UI in app designer. It contains a list box in which one can add the items (file paths).
When the list box displays several items, it is possible to select one of them and the callback is the following:
app.SelectedVideo2 = app.VideoFilesListBox_2.Value;
This new variable is used afterwards for video preview.
However, when only one item in the listbox is displayed, it is not possible to select it and the variable app.SelectedVideo2 does not change.
How can I solve this problem?

Accepted Answer

Jessica Angulo Capel
Jessica Angulo Capel on 31 Jul 2020
I found the problem. It seems the callback is only called when the value is changed (ValueChangedFcn callback). Therefore, given there is only one item, it can not "be changed" and the callback does not work.
  1 Comment
Marcus Adkins
Marcus Adkins on 1 Sep 2023
That's the answer to your problem - but not a fix. I have code that populates other items in the GUI based on the listbox selection and if I only have one item, I'm stuck. The only workaround I can think of so far is to insert a 'dummy' first item and then have my code ignore that if selected. It's pretty ugly.

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!