Hi!
I am currently creating an app with AppDesigner and I am struggling with a problem I can't solve. Here is the situation : I created 2 different tabs in a panel, and depending on the tab I am currently on, I'd like to give a button differents actions to do.
My problem is : I don't know how to implemant the fact that I am in the tab1 or the tab2, and thus, the button doesn't work the way I want.
Thank you for helping!

 Réponse acceptée

Mario Malic
Mario Malic le 11 Avr 2021

0 votes

Hello,
Tabs are children of the TabGroup component. The latter component has property called SelectedTab which will be helpful.

4 commentaires

Aurélie B
Aurélie B le 11 Avr 2021
Thank you for answering! I found out this, but I can't give a default value.
When I open the app, I'd like the selected tab to be the first one by default. For now, I can access to this part of the code only when I go to the second tab and then come back to the first one.
I wrote this function to consider app.VueTab as a default value, but it doesn't work..
function TabGroupSelectionChanged(app, event)
selectedTab = app.TabGroup.SelectedTab;
switch selectedTab.Title
case 'Segmentation'
app.selection= app.SegmentationTab;
otherwise
app.selection = app.VueTab;
end
end
Do you know what sould I add in order to make it work?
You can add this in the StartupFcn and it should be fine.
app.selection= app.SegmentationTab;
Aurélie B
Aurélie B le 11 Avr 2021
Thank you so much, it works !
By the way, you don't need to create a property nor the callback to use in your calculations, when app gets more and more complex, debugging can be problematic.
It is better to reference the components directly in the calculations.
function calculate(app)
if strcmpi(app.TabGroup.SelectedTab.Title, 'Segmentation')
% do this
else
% do that
end
end

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by