UIContextMenu disabled when axes is used

2 Ansichten (letzte 30 Tage)
Jakob Sørensen
Jakob Sørensen am 19 Mai 2014
Beantwortet: Jakob Sørensen am 19 Mai 2014
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 Kommentar
Jakob Sørensen
Jakob Sørensen am 19 Mai 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jakob Sørensen
Jakob Sørensen am 19 Mai 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.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by