How to detect the calling axes from context menu using AppDesigner

6 ビュー (過去 30 日間)
Kristoffer Walker
Kristoffer Walker 2020 年 10 月 21 日
コメント済み: Kristoffer Walker 2020 年 10 月 27 日
Hello Folks,
I hope you are all staying safe out there.
I am in the middle of a development project. So I have been posting several questions today (my apologies).
I am using App Designer to make an interconnected series of GUI's. One of the GUI's has many axes in it. I want to create a simple Context Menu that I can share between the different axes. I want the callback to get the current x and y limits of the axis, remind the user what they are, then accept input from the user to change it to something else. However, I can't seem to figure out how to get the handle of the axes within which the context menu was triggered from inside the callback. I have searched, but failed to find anything on this topic that I have recognized to be within the App Designer construct (lots of GUIDE construct posts though). Could any of you point me in the right direction?
Best regards,
Kris

採用された回答

Ayush Bansal
Ayush Bansal 2020 年 10 月 27 日
Assign the object of ContextMenu to the axes property ContextMenu.
  3 件のコメント
Ayush Bansal
Ayush Bansal 2020 年 10 月 27 日
Use event.Source.Parent.CurrentAxes.XLim to access x limit of the current axis, which triggered the context menu.
Event property "Source" is the context menu which triggered the event.
Context Menu property "Parent" is the figure on which Context menu was triggered.
Figure property "CurrentAxis" is the axes on which the context menu was trigeered
Axes property "XLim" is the vector of limits in x axis for plot.
Kristoffer Walker
Kristoffer Walker 2020 年 10 月 27 日
Hi Ayush,
Many thanks for the quick reply! Your solution was mostly correct. Just needs an extra "Parent" in there to back out of the context menu list panel.
XLimits = event.Source.Parent.Parent.CurrentAxes.XLim
Thanks again!
Kris

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by