Same Context Menu for Different Items in Tree

I am trying to utilize one context menu in a tree in Appdesigner. The actions that come with the context menu will be dependent on the node that was right-clicked. The tree is also built manually or imported. I have successfully added context menus to each item as it's built, but they all lead to the same function. For example, I want to right click on a treenode and select a remove function to delete it from the tree. However, I can't find a way to see which of the nodes was right clicked to remove it. The tree has a selected nodes property, but right clicking a node does not actually select the node. How do you get the node that was right clicked?
A workaround would be to select the node when it is right clicked. I'm unsure how to accomplish this.
Another way is to create a new context menu for every item on the list, but this seems extremely inefficient.
Any help is appreciated!
I am using appdesigner on 2020a.

2 个评论

I have the same problem and this is the answer I got from MathWorks
"I did had a chance to work with my colleagues on this. Unfortunately, currently there is no way to find out which object the user right-clicked on inside 'uimenu' callback function. Although 'gco' can be used to find out the last object clicked over a figure but it does not work with 'uimenu'.
I have provided the feedback to respective team of this enhancement/feature and they will be looking into this for future MATLAB releases."
Hi,
Do you find a way to tackle this isuue?

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by