필터 지우기
필터 지우기

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 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