Combining Matlab and Java callbacks

Hi there,
I am working on a more complex GUI application with several axes objects. For pan and zoom in the axes I am using java callbacks of the parent uicontainer object of the axes object (Axes has no java object). This works quite good.
Now I tried to add a uicontextmenu to my axes. I discovered that it will never show up as long as a java callback on the parent object is active. If i deactivate the java callbacks for testing, the contextmenu works as expected. I also tried to use the "ButtonDownFcn" for some plotted lines. It shows exactly the same behavior.
It seems that, somehow, the java callbacks are preventing the execution of all axes callbacks. Is it possible to workaround this behavior? Can I forward the callback somehow to the axes?
Thanks for any help
Here is a small example wich simplifies the problem
fig = figure;
panel = matlab.ui.container.internal.UIContainer('Parent', fig);
jpanel = panel.JavaFrame.getPrintableComponent;
jpanel= handle(jpanel, 'CallbackProperties');
% comment the next two lines if you want to see the context menu
set(jpanel, 'MouseDraggedCallback', @(h,e)disp('drag'));
set(jpanel, 'MouseClickedCallback', @(h,e)disp('Click'));
ax = axes('Parent', panel);
plot(ax, 1:5,1:5);
hcmenu = uicontextmenu;
uimenu(hcmenu, 'Label', 'item 1', 'Callback', @(h,e)disp('item 1'));
ax.UIContextMenu = hcmenu;
I am using Matlab 2016a

댓글 수: 1

Adithya Addanki
Adithya Addanki 2016년 3월 30일
Hi Marco,
I tried reproducing the same at my end. I was able to observe the same behavior as you mentioned. However, I was not able to find any workarounds so far.
I would suggest you to reach out to MathWorks Technical Support for assistance regarding this issue, as it may need further investigation and to see if there is any possible workaround for this workflow. You may email support@mathworks.com or call us at 508-647-7000.
Thank you, Adithya

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

질문:

2016년 3월 25일

댓글:

2016년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by