UIContextMenu disabled when axes is used

2 visualizaciones (últimos 30 días)
Jakob Sørensen
Jakob Sørensen el 19 de Mayo de 2014
Respondida: Jakob Sørensen el 19 de Mayo de 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 comentario
Jakob Sørensen
Jakob Sørensen el 19 de Mayo de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Jakob Sørensen
Jakob Sørensen el 19 de Mayo de 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.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by