UIContextMenu disabled when axes is used

2 views (last 30 days)
Hi there,
I've created a small GUI using the GUIDE tool (its the lazy way, I know). I have an axes I use to show an image, and I would like to add an option to save that image. I wanted to do so by adding an uicontextmenu (right-click menu), with a "Save image as..." option. I've create the menu and added it to the axes, which works fine initially. However when I use the axes to show the image (doesn't happen until you click a button), the uicontexmenu no longer works.
Is there any clever way to fix this? An option where the uicontextmenu is added after the image is shown, is perfectly acceptable (in fact it would be preferred). I've tried the following line of code, but that does not work:
set(handles.axesMainAxes, 'uicontextmenu', cMenu_axesMainAxes_Callback);
Any help is greatly appreciated, thanks :-).
  1 Comment
Jakob Sørensen
Jakob Sørensen on 19 May 2014
Update: I changed the code line to the following
set(handles.axesMainAxes, 'uicontextmenu', handles.cMenu_axesMainAxes);
and I no longer recieve any errors from the code. The uicontextmenu still does not work however.

Sign in to comment.

Accepted Answer

Jakob Sørensen
Jakob Sørensen on 19 May 2014
It solved it to add the uicontextmenu to the image, rather than to the axes. So when displaying the image, add the menu:
image(classifiedImage,'uicontextmenu',handles.cMenu_axesClassification);
Also remember the handles. in front of the uicontextmenu tag name, and remember that it is the tag name, not the function name which should be used.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!