In a callback, how do I determine which mouse button was pressed to generate the callback?
13 views (last 30 days)
Show older comments
I would like to determine, in a callback, which mouse button was pressed to generate the callback.
Accepted Answer
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.
0 Comments
More Answers (0)
See Also
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!