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

68 次查看(过去 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-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