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 Comments

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?

Sign in to comment.

Answers (0)

Categories

Products

Release

R2020a

Asked:

on 17 Apr 2020

Community Treasure Hunt

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

Start Hunting!