Effacer les filtres
Effacer les filtres

Detecting which mouse button is pressed in a UIFigureWindowButtonDown callback

25 vues (au cours des 30 derniers jours)
Andrei Veldman
Andrei Veldman le 23 Oct 2019
Commenté : Alexander Melin le 19 Juil 2022
In App Designer, how how can I detect which mouse button (Left, Right, Middle) was pressed in a UIFigureWindowButtonDownUIFigureWindowButtonDown callback?
  3 commentaires
Andrei Veldman
Andrei Veldman le 23 Oct 2019
Thanks Shubham, the answer your link points to works just fine!
I've done before what that answer suggests for regular figures (created in guide), but I thought that MathWorks may have changed teh way it works for UIFigure , perhaps passing the button information in the event input, which would be teh natural way, I think.
If I knew how to accept your comment as the correct answer, I would. Perhaps that's only possible for answers, not comments.
Alexander Melin
Alexander Melin le 19 Juil 2022
The newer (possibly more elegant) solution uses the event information. Using the UIFigure UIFigureWindowButtonDown callback, the event object passed to the callback has information on the source of the event (mouse click), in this case the UIFigure. Then you can directly access the SelectionType property. For example
% Window button down function: UIFigure
function UIFigureWindowButtonDown(app, event)
switch event.Source.SelectionType
case 'normal'
% Do left button stuff
case 'alt'
% Do right button stuff
case 'extend'
% Do center button stuff
end
end

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Develop uifigure-Based Apps 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!

Translated by