Is uicontextmenu working for R2020a? // Answer: NO. Use R2019b instead.

조회 수: 1 (최근 30일)
Jose Rego Terol
Jose Rego Terol 2020년 12월 10일
편집: Bruno Luong 2020년 12월 10일
Hi all,
So I have this function to zoom and pan the plot by clicking the right mouse button.
function zoom_pan
hCM = uicontextmenu;
hMenu = uimenu('Parent',hCM,'Label','Switch to zoom',...
'Callback','zoom(gcbf,''on'')');
hPan = pan(gcf);
hPan.UIContextMenu = hCM;
pan('on')
hCMZ = uicontextmenu;
hZMenu = uimenu('Parent',hCMZ,'Label','Switch to pan',...
'Callback','pan(gcbf,''on'')');
hZoom = zoom(gcf);
hZoom.UIContextMenu = hCMZ;
zoom('on')
end
The function allows me to switch between zoom and pan.
Yesterday, this function worked. But suddenly today is not working.
In this order, the default function is zoom-in. However, I cannot switch to pan function.
If I reverse the order, I can switch from pan to zoom, but I cannot go back to pan. This function was amazing for this purpose. Pan and zoom really fast and always available but clicking the right mouse button.
Do you know if the is some update regarding this uicontextmenu with R2020a?
  댓글 수: 3
Rik
Rik 2020년 12월 10일
When I run your code in R2020b, I get the expected result: a right-click context menu that allows me to switch back and forth between pan and zoom.
figure(1),clf(1),plot(rand(10,2))
zoom_pan % works as expected
I has the exact same behavior on R2018a, so I don't see what you mean. Are you getting any error?
Bruno Luong
Bruno Luong 2020년 12월 10일
편집: Bruno Luong 2020년 12월 10일
uicontextmenu always works, up to R2020b, on standard figure/axes. You might experience different on uifigure, uiaxes.
Also pay attention if the uicontextmenu is not shadowed by other graphic objects that are plots on the same container.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by