(App Designer) ListBox Callback - does my value need to change to get a callback?

36 views (last 30 days)
Hi all,
I have a ValueChangedFnc (Value changed function) for my listbox that correctly responds when I select a different item in my list. I would like the same callback to occur when I click the currently selected item (the value does not change but I would like to repeat the callback).
Is there any other way to add callbacks to the listbox? or do I need to de-select the current item in order to repeat it?
Thanks!
HG
  3 Comments
Hannah Gillespie
Hannah Gillespie on 24 Jun 2019
Hi Geoff,
I basically have two listboxes, one contains x axis information and one contains y axis information. When I select any item in the y axis information box, my gui plots it with respect to whatever is selected in the x axis information box. Now I want to be able to compare the plots with other conditions, so I want to plot the same y axis information with different data sets uploaded. However, my y axis selection is not deselected and I cannot plot the same y data again without first selecting something different. Thanks!
Marcus Adkins
Marcus Adkins on 1 Sep 2023
Yes, this is a real pain. I initially populate the listbox from an input file (i.e. the items are not set until a file is loaded). I would like to select the listbox item and have it deconstruct the menu string to populate other fields which can then be used, modified, etc. This works fine if the initial data file has more than one item, but if there is only one then I'm stuck.
If anyone finds a workaround for this, I would be very interested.

Sign in to comment.

Answers (1)

Guillaume
Guillaume on 24 Jun 2019
It sounds like you need to change your design slightly. At the moment, it sounds like you're only plotting when y changes but actually you also want to plot when some other information changes. So, extract the plotting code in its own function and call that plotting function from the callback of each relevant control (x, y, etc.)
  6 Comments
Lee
Lee on 2 Aug 2022
How can you say this is not reduced functionality? I am experiencing the same problem, whereby after migrating from GUIDE to App Designer, callbacks are no longer firing. I have multiple listboxes, with common action buttons, so it's necessary to know which listbox is currently 'active'. In GUIDE, it was enough to just click inside the Listbox. Now the callback only activates if the value is changed > so what if my listbox sometimes only contains one value? It is now IMPOSSIBLE to 'activate' this listbox. I may be forced to duplicate all my buttons for every listbox unless I find a workaround...
Still think we have the same functionality? objectively NO. Matlab could simply add a kind of SelectionCallback, but there is no option to add any callback other than ValueChanged, thank you Mathworks!
Marcus Adkins
Marcus Adkins on 1 Sep 2023
OK. Here's an ugly workaround:
When populating my listboxes, I insert a dummy first item with a recognized pattern (space, special character or something). In my callback code, I have a line to ignore that if selected, i.e. the listbox only reacts if one of the other lines are selected. It's not elegant but at least it will allow me never to get 'stuck' by only having one item in the listbox to operate on.
It would be much better if Mathworks simply offered a 'selected' callback for listboxes in addition to the 'value changed' callback which is the only option now.

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps 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!