How to create different callbacks for left and right click on a figure object?
59 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2012-3-23
编辑: MathWorks Support Team
2020-7-7
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!