필터 지우기
필터 지우기

In App Designer, the TabGroup callbacks are no longer defined when i restart matlab. Why?

조회 수: 12 (최근 30일)
Hi, I'm designing a simple app. It's got two Tab Groups, each with two tabs. Each tab has a drop down menu. When I change the selected tab, I want to save the title of the new tab in a Matlab preference. Here is example code for a single 'SelectionChangedFcn' callback, the second Tab Group would have an analogous one.
function TabGroupSelectionChanged(app)
selectedTab = app.TabGroup.SelectedTab;
setpref('GUIstatus','prop',selectedTab.Title)
switch selectedTab.Title
case 'PropValue1'
value = app.DropDown.Value;
setpref('GUIstatus','Subprop',value)
case 'PropValue2'
value = app.DropDown2.Value;
setpref('GUIstatus','Subprop',value)
end
end
I created this callback by right clicking on the Tab Group in the component browser, and clicking Callbacks. This worked, the callback executed when I ran the app and clicked on the Tab. When I restarted Matlab, it no longer worked. The callback function still existed in the code, but the Tab Group component no longer had a callback property. When I tried to enter the name of the function 'TabGroupSelectionChanged' as the callback, a dialogue window came up with the following code: 'Name is already defined as an App Callback.' The solution was to create new callback functions and delete the old ones, but as soon as I restarted Matlab, the same problem occured.
Any ideas on how to get the callbacks to stick? Thanks a ton.
System info:
>> ver
----------------------------------------------------------------------------------------------------
MATLAB Version: 9.0.0.341360 (R2016a)
MATLAB License Number: yada yada
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 15063)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
educational license will all the toolboxes

답변 (1개)

Aoyu Chen
Aoyu Chen 2017년 9월 6일
You need to put the .mlapp file either in the current folder or on the MATLAB search path. Please refer to the following documentation links as instructions:
https://www.mathworks.com/help/matlab/matlab_env/add-remove-or-reorder-folders-on-the-search-path.html https://www.mathworks.com/help/matlab/ref/addpath.html

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by