Azzera filtri
Azzera filtri

App Designer: Use a button in one .mlapp file to open a specific UItab in a different .mlapp file

1 visualizzazione (ultimi 30 giorni)
I would like to use a button in one .mlapp file to open a specific UItab in a different .mlapp file in app designer. When I use 'appname.uitab_2' I get the error "The property 'uitab_2' in class 'appname' must be accessed from a class instance because it is not a Constant property."
Any help would be appreciated.

Risposte (1)

Elizabeth Reese
Elizabeth Reese il 14 Ago 2017
Let the app with the button be called app1 and the app with the tab group be called app2. In app2, let the tab group be called TabGroup and the two tabs be called Tab1 and Tab2.
Within app1,
  • Add a property (I will call it app2_handle)
  • Add a startupFcn callback to the UIFigure
  • In the startupFcn, call the constructor for app2 and assign the handle to app2_handle.This function in app1 looks like:
function startupFcn(app)
app.app2_handle = app2();
end
This makes app1 open an instance of app2. Now you can manipulate app2 from app1.
  • Add a ButtonPushed callback to the button in app1.
  • In ButtonPushed, use app2_handle to manipulate the SelectedTab. An example of this function could be:
% Button pushed function: Button
function ButtonPushed(app, event)
selected = app.app2_handle.TabGroup.SelectedTab;
if (selected == app.app2_handle.Tab1)
app.app2_handle.TabGroup.SelectedTab = app.app2_handle.Tab2;
else
app.app2_handle.TabGroup.SelectedTab = app.app2_handle.Tab1;
end
end

Categorie

Scopri di più su Develop uifigure-Based Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by