How to specify a callback function for the CellSelectionCallback property for runtime created Tables in App Designer?

3 ビュー (過去 30 日間)
In App Designer:
Suppose that a TabGroup is created in App Designer's Design View, and that new tabs are simply added at runtime:
hTab = uitab(app.TabGroup,'Title',name_string);
Then suppose that a table is created as a child of the new tab, with a function specified for the CellSelection callback:
hTable = uitable(hTab,'CellSelectionCallback',@TableCellSelection);
The function TableCellSelection(app,event) is a private method in the app.
When the user selects some region of a successfully populated table, the following error results:
Undefined function 'TableCellSelection' for input arguments of type 'matlab.ui.control.table'.
Am I using an incorrect approach, or is this possibly a bug? Thanks.

回答 (1 件)

Kevin Holly
Kevin Holly 2023 年 7 月 26 日
MrToad,
It seems like MATLAB cannot locate the function. You could call the function from outside the app. Please see the app and script attached.
In the example attached, I called the function with app as an input:
hTable = uitable(hTab,'CellSelectionCallback',{@TableCellSelection app});
To test to see if the function works, I had it make a label visible.
function TableCellSelection(table_handle,events,app)
app.CellSelectionworksLabel.Visible = "on";
end

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by