How do I get the UICONTEXTMENU to appear on an image in my GUI that I created using GUIDE?
6 views (last 30 days)
Show older comments
I am inserting an image in one of the axes that I have in my GUI using the following code:
axes(handles.axes3);
Im=image(imread('flowers.tif'));
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?
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
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:
axes(handles.axes3);
Im=image(imread('flowers.tif'),'hittest','off');
0 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!