フィルターのクリア

Appdesigner uiaxes data tip context menu

12 ビュー (過去 30 日間)
John H.
John H. 2023 年 4 月 17 日
コメント済み: John H. 2023 年 5 月 1 日
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 Center および File ExchangeInteractive 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