How to create different callbacks for left and right click on a figure object?

조회 수: 66 (최근 30일)
I have an axes and I wish to execute two different functionalities on left and right click on the figure.
For example, when I right click I want to the open the UICONTEXT MENU, and when I left click I want the figure to update with new data, or open another GUI.
Currently, when I right click it open the UICONTEXT menu and also fires open a new GUI.
How do I create different functionalities for the left and right click of the mouse?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2020년 9월 14일
편집: MathWorks Support Team 2020년 7월 7일
The figure contains the 'SELECTIONTYPE' property which changes depending up on the type of click and ENABLE property of the particular UICONTROL/ figure object.
Detailed description of values that this property can take can be found at the following link in the documentation:
In your GUI, create cases in the BUTTONDOWNFCN of the UICONTROL/FIGURE OBJECT based on the value of 'SELECTIONTYPE' that you desire so that you can place code for action after left or right clicks in the appropriate case.
I have attached an example to demonstrate this behavior, look at the BUTTONDOWNFCN of the AXES. Here the figure does not fire the action for left click on a right click event.
I have also attached an example that demonstrates how to do this for other objects, such as a line object.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by