In a callback, how do I determine which mouse button was pressed to generate the callback?

I would like to determine, in a callback, which mouse button was pressed to generate the callback.

 Réponse acceptée

You can determine which mouse event has occurred by examining the 'SelectionType' property of the figure. The property can take the following values:
1. normal: left mouse button
2. extend: right mouse button on a 2-button mouse;
middle mouse button on a 3-button mouse
3. alt: left+right buttons on a 2-button mouse;
right mouse button on a 3-button mouse
4. open:double mouse click
For example, you can see the values taken by executing the following:
figure;
set(gcf,'WindowButtonDownFcn', 'disp(get(gcf,''SelectionType''));');
Now click in the current figure to see the values displayed.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by