Appdesigner uiaxes data tip context menu
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
John H.
am 17 Apr. 2023
Kommentiert: John H.
am 1 Mai 2023
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?
0 Kommentare
Akzeptierte Antwort
Eswaramoorthy
am 1 Mai 2023
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!
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!