Hi, I'd like to create a ContextMenu for a ListBox in my app where the callbacks are aware of which item in the ListBox was selected. Is there a way to create the ContextMenu for each item, or can I only do it for the entire ListBox?
If the latter, how could I figure out which item I chose when entering the menu?

댓글 수: 6

Jan
Jan 2021년 4월 1일
Is this a uifigure or figure?
J. Alex Lee
J. Alex Lee 2021년 4월 1일
it seems to me at this point you are asking more of the listbox than it is useful for, and more important maybe more of the user than how they would intuitively interact with one...is there some other ui element or elements that would better serve your purpose?
Cyrano Chatziantoniou
Cyrano Chatziantoniou 2021년 4월 1일
I'm not sure, what would you suggest as an element that can list multiple items as well as support many callbacks to different functions?
Cyrano Chatziantoniou
Cyrano Chatziantoniou 2021년 4월 1일
It's a uifigure.
J. Alex Lee
J. Alex Lee 2021년 4월 1일
@Cyrano Chatziantoniou, for example another list box that dynamically populates depending on the value of the first list box would be a simple one. I think the number of clicks would be the same as your original idea, but maybe you have to move the mouse cursor a little bit farther away...
anyway it's hard to know without knowing more about what you want to accomplish
J. Alex Lee
J. Alex Lee 2021년 4월 1일
actually, the context menu itself can be nested, so probably the most obvious way would be just to start with a context menu and use context menus all the way down...but again, depends on what exactly the behavior/outcome is that you are after.

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

답변 (1개)

Jan
Jan 2021년 4월 1일
편집: Jan 2021년 4월 1일

0 개 추천

For the Java based listboxes in figures (not uifigures), see: https://undocumentedmatlab.com/articles/setting-listbox-mouse-actions

댓글 수: 1

Bruno Luong
Bruno Luong 2021년 4월 1일
Pitty that a lot of java-based tricks from undocumented matlab won't work with MATLAB app.

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

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2021년 4월 1일

댓글:

2021년 4월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by