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.
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!