(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
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
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
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
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 Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!