How do you display in a uicontextmenu the coordinates of the point in a uiimage of a uifigure clicked by the user while opening the context menu? Here is the code template. It shows how you can dynamically change the content of a uicontextmenu, but fails to capture the coordinates of the clicked point. Note that the coordinates of the clicked point are given by the property CurrentPoint of uiaxes and uifigure. The uiaxes information is not available since there are no axes, having created the image with the uiimage function, and the property is zero for uifigure.
function menucoordinates
fig = uifigure;
cm = uicontextmenu(fig);
cm.ContextMenuOpeningFcn = @onRightClick;
m = uimenu(cm,'Text','');
im = uiimage(fig);
im.ImageSource = 'membrane.png';
im.ContextMenu = cm;
function onRightClick(src,event)
disp(fig.CurrentPoint)
x = 1;
y = 1;
m.Text = ['x ',num2str(x),', y ',num2str(y)];
end
end
0 Comments
Sign in to comment.