Appdesigner uiaxes data tip context menu

9 次查看(过去 30 天)
Hello,
I have made an app in appdesigner which has a UIAxes with data plotted on it.
When I create a data tip, i am able to right click on the data tip and have a context menu appear.
I would like to modify that context menu to add some menu items that link to callbacks.
Is this possible?

采纳的回答

Eswaramoorthy
Eswaramoorthy 2023-5-1
Yes, it is possible to modify the context menu of a data tip in MATLAB App Designer to add menu items that link to callbacks.
Here are the steps you can follow to achieve this:
1. Create a context menu object using the uicontextmenu function.
myContextMenu = uicontextmenu;
2. Add menu items to the context menu object using the uimenu function. Specify the label for the menu item and the callback function that should be executed when the menu item is selected.
menu1 = uimenu(myContextMenu,'Label','Menu Item 1','Callback',@myCallback1);
menu2 = uimenu(myContextMenu,'Label','Menu Item 2','Callback',@myCallback2);
3. Attach the context menu object to the data tip using the set function.
dcm_obj = datacursormode(gcf);
set(dcm_obj,'UiContextMenu',myContextMenu);
4. Define the callback functions that should be executed when the menu items are selected.
function myCallback1(~,~)
disp('Menu Item 1 selected');
end
function myCallback2(~,~)
disp('Menu Item 2 selected');
end
With these steps, you should be able to modify the context menu of the data tip in your MATLAB App Designer app to add menu items that link to callbacks.
Hope this helps!
  1 个评论
John H.
John H. 2023-5-1
a very thorough and descriptive answer, thankyou!
i will give this a shot in the near future =)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by