How to invoke callback when UITable cells are deselected in App Designer?

I have a UI table object in an App Designer project and would like to implement buttons to insert and delete table rows. In the UITable cell selection callback, I store the addresses of selected cells and enable the "insert row" and "delete row" buttons. However, if the user clicks on the white space below the UITable cells, the cells will deselect, but the cell selection callback is not invoked. I would like to disable the "insert row" and "delete row" buttons when cells are no longer selected- otherwise, the user can insert rows at the last cell selected, even when no cells appear to be selected.
Things that didn't work:
  • I tried to use the UIFigure ButtonDwnFcn and the UIFigure WindowButtonDwnFcn callbacks, but neither of these invokes when I press the white space on the UITable.
  • It doesn't work to just make the UITable smaller initially, because the user can delete rows until the white space shows again, or can resize the window and make the white space show again.
Picture of the white space that clears the cell selection when you click it:
Capture.PNG
Callback function:
% Cell selection callback: UITable
function UITableCellSelection(app, event)
if isempty(event.Indices)
app.InsertrowaboveButton.Enable = 'off';
app.InsertrowbelowButton.Enable = 'off';
app.DeleterowButton.Enable = 'off';
else
app.minRow = event.Indices(1,1);
app.maxRow = event.Indices(end,1);
app.InsertrowaboveButton.Enable = 'on';
app.InsertrowbelowButton.Enable = 'on';
app.DeleterowButton.Enable = 'on';
end
end

2 Comments

Did you ever figure this out? I'm having a similiar issue. I would like to have a way to have a callback function for when the user clicks the white space you are refering to above. Thanks in advance!
There is a reply witha solution in this thread
https://de.mathworks.com/matlabcentral/answers/414423-app-designer-uitable-cell-selection-callback-event-for-deselecting-cells

Sign in to comment.

Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products

Release

R2019a

Asked:

on 6 Aug 2019

Commented:

on 1 Feb 2022

Community Treasure Hunt

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

Start Hunting!