How do I get the UICONTEXTMENU to appear on an image in my GUI that I created using GUIDE?
6 views (last 30 days)
I am inserting an image in one of the axes that I have in my GUI using the following code:
axes3 is the handle for the axes where I want to insert the image. I have a UICONTEXTMENU associated with this axes. However, if I right click on the image, I do not get the UICONTEXTMENU. I have to right click either on the X or Y axis of the axes to get the UICONTEXTMENU.
How do I get the UICONTEXTMENU to appear by clicking anywhere on the image and not only on the X or the Y axis of the axes?
When you right click on the image, it becomes the current object and not the axes which contains it. The UICONTEXTMENU is associated with the axes. That's why it appears only when you right click on the X or the Y axis of the axes as the axes becomes the current object.
To get the UICONTEXTMENU when you right click on the image, you have to make sure that the image does not become the current object. To achieve this, you will have to set the 'HitTest' property of the image to 'off' (this property is set to 'on' by default).
Here is an example: