Add context menu when LEFT click on button (app design)
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi!
I am trying to add kind of a context menu after LEFT pushing a button on a specific tab of my app, but it seems not to be allowed. Suggestion for a workaround?
function ButtonAddPlotPushed(app, event)
cm = uicontextmenu(app.UIFigure); %
m1 = uimenu(cm,'Text','Menu1');
m2 = uimenu(cm,'Text','Menu2');
m3 = uimenu(cm,'Text','Menu3');
pos = app.ButtonAddPlot.Position(1:2)
set(cm,'Position',pos);
set(cm,'Visible','on');
end
My GUI is something like this:
I need something like this:
I can't use a toolbar instead, because I need it just below the "Output Visualization" tab, while the toolbar is added on the top of the app:
3 commentaires
Réponses (2)
Vimal Rathod
le 23 Juin 2021
Hi,
You could try setting up 'HitTest' property of the Image to 'off' that way your UI could register its clicks and hopefully you could call the contextmenu.
Following link contains question similar to yours
1 commentaire
Johan C
le 11 Août 2021
Modifié(e) : Johan C
le 11 Août 2021
This work for me, hope it helps.
properties (Access = private)
cm % Description
end
function startupFcn(app)
% Create ContextMenu
app.cm.ContextMenu = uicontextmenu(app.UIFigure);
% Create Menu1
app.cm.Menu1 = uimenu(app.cm.ContextMenu);
app.cm.Menu1.Text = 'menu1';
% Create Menu2
app.cm.Menu2 = uimenu(app.cm.ContextMenu);
app.cm.Menu2.Text = 'menu2';
end
function ButtonPushed(app, event)
open(app.cm.ContextMenu ,event.Source.Position([1 2]))
end
Best JC
0 commentaires
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!