What's the callback function for "selecting" a TAB?

74 ビュー (過去 30 日間)
John
John 2020 年 3 月 4 日
編集済み: Adam Ambarus 2022 年 7 月 19 日
Using App Designer with Tab-Group and Tabs. Now want to create and access to the call back function when the Tab is selected. With the right mouse button or help, it has "SizeChangedFcn".
How to make callback function for "selecting" thr Tab?
Also, it gives: [ 'SizeChangedFcn' callback will not execute while 'AutoResizeChildren' is set to 'on' ], even AutoResizeChildren are all set to 'OFF'.
What can stop these warnings?
Thank you for your help.
  2 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 3 月 5 日
John - I think that you want to use the SelectionChangedFcn callback. (I'm not sure about the warnings...)
Walter Roberson
Walter Roberson 2020 年 3 月 6 日
John comments:
Thanks!

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

採用された回答

Harshendra Shah
Harshendra Shah 2020 年 4 月 9 日
Hi John,
In order to set a call back to for Tab changes we require "TabGroupSelectionChanged" callback function from "TabGroup" instead of an individual "Tab".
This is how you can attach the callback in App Designer :
This callback will trigger when you have switched to a new tab, e.g., by clicking on the tab.
You may use the "app.TabGroup.SelectedTab" property to either get or set the currently selected tab. The following example shows how to do this.
>> selectedTab = app.TabGroup.SelectedTab;
>> app.TabGroup.SelectedTab = app.TabA;
This example shows how to detect that the user has switched to "TabA".
function TabGroupSelectionChanged(app, event)
if app.TabGroup.SelectedTab.Title == app.TabA.Title
%Code here runs when TabA is selected
end
end
Regarding your second query on warning "'SizeChangedFcn' callback will not execute while 'AutoResizeChildren' is set to 'on'", you can refere to the following MATLAB Answers:
It will give you a good understanding for why you are getting this warning.
I hope this helps.
  1 件のコメント
Adam Ambarus
Adam Ambarus 2022 年 7 月 19 日
編集済み: Adam Ambarus 2022 年 7 月 19 日
That condition might throw errors, try:
if strcmp(app.TabGroup.SelectedTab.Title, app.TabA.Title)
end

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by