UIContextMenu disabled when axes is used

3 ビュー (過去 30 日間)
Jakob Sørensen
Jakob Sørensen 2014 年 5 月 19 日
回答済み: Jakob Sørensen 2014 年 5 月 19 日
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 件のコメント
Jakob Sørensen
Jakob Sørensen 2014 年 5 月 19 日
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.

サインインしてコメントする。

採用された回答

Jakob Sørensen
Jakob Sørensen 2014 年 5 月 19 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by