Combining Matlab and Java callbacks
3 ビュー (過去 30 日間)
古いコメントを表示
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
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 件)
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!