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

조회 수: 37 (최근 30일)
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
Hannah Gillespie
Hannah Gillespie 2019년 6월 24일
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 2023년 9월 1일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2019년 6월 24일
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
Lee
Lee 2022년 8월 2일
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 2023년 9월 1일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by