Interactive with graphics in GUI

6 ビュー (過去 30 日間)
Ivan Sokolov
Ivan Sokolov 2021 年 5 月 4 日
コメント済み: Ivan Sokolov 2021 年 5 月 4 日
I have context menus on axes. It is called on the left mouse button.
But I cannot bring up this menu on the blue line. This line is built using plot. If I add a polygon, then I can't bring up the menu on it either but it is necessary.
I don't interact with drawn objects.
Maybe there is an opportunity to send the drawing to the background? I ask for help with this.

採用された回答

Steven Lord
Steven Lord 2021 年 5 月 4 日
ax = axes('ButtonDownFcn', @(varargin) disp('hi'));
Click on the axes. MATLAB will display hi in the Command Window.
Now add a line to the axes.
hold on
h = plot(1:10, 1:10);
If you click on the axes but not the line you will still see hi displayed. If you click on (or close enough to) the line you will not see anything new displayed in the Command Window.
Now tell MATLAB to ignore the line when it's determining what you clicked on.
h.HitTest = 'off';
After running that command clicking on the axes and clicking on or near the line will display hi.
  1 件のコメント
Ivan Sokolov
Ivan Sokolov 2021 年 5 月 4 日
Thanks, it works.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by