Make UIAxes invisible/visible when stacked in App desginer..

21 ビュー (過去 30 日間)
Jack Latham
Jack Latham 2019 年 10 月 1 日
編集済み: Adam Danz 2020 年 9 月 20 日
I'm using App designer to desing an app.. I have a couple of UIAxes stacked above each other, and am trying to set ones I want to see to being visible and the others to not visible, using:
app.UIAxes.Visible = 'off';
Which works fine, but the UIAxes below remains hidden! For example if I have two axes overlapping only partially, and make the one 'on top' invisible, the one 'on top' goes, but the portion on the other axes which was hidden, remains hidden!!
Frustating problem, any solutions would be great!
  1 件のコメント
Adam Danz
Adam Danz 2019 年 10 月 3 日
Any luck implementing the propsed answer?

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

採用された回答

Adam Danz
Adam Danz 2019 年 10 月 1 日
編集済み: Adam Danz 2020 年 9 月 20 日
Update: Starting in Matlab r2020b, change the stack order of UI components in App Designer using the reorder tool (see release notes).
----------------------------------------------------------------------------------------
Unfortunately uistack() is not functional with UIFigures (prior to r2020b). Here's a function you could embed in your app that will put an object on top of the UI stack. Add the function by opening the app in app designer, go to code view, select functions, and add the function by pressing the green "+" under the Code Browser. Then call the function any time an object needs to be moved to top. Unfortunately the app image will flicker during the restack as the objects are redrawn.
function uistackTop(~, appfig, obj)
% Place the UI object 'obj' on top of stack in the UIfigure 'appfig'
appHandles = appfig.Children; % list all handles in app
hIdx = find(appHandles==obj); % find index of obj in appHandles
% Create new index order of app handles
newOrder = [hIdx,setdiff(1:numel(appHandles),hIdx)];
% assign new stack order to app
appfig.Children = appHandles(newOrder);
Example:
appfig = app.myAppFig; % Handle to your App figure
obj = app.UIAxes2; % handle to the object that goes on top
uistackTop(app, appfig, obj)
Also see this answer for a function that moves a UI object to the bottom of the stack.
  2 件のコメント
Jack Latham
Jack Latham 2019 年 10 月 4 日
Thank you for the answer! I ended up plotting to a Panel and making new axis instead when I wanted the new view, this solution may be better
Adam Danz
Adam Danz 2019 年 10 月 4 日
That's not a bad idea.
Another idea might be to use UI Tabs. Instead of making new axes or changing the UI stack, you can just switch back and forth between tabs that are all located in the same position.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by