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 年 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 Center および File ExchangeGraphics Object Programming についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by