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

13 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
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.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!