MATLAB Answers

Implementing multiple selection and selection range for UITable in App Designer

55 views (last 30 days)
Fatai Anifowose
Fatai Anifowose on 23 Mar 2020
Commented: JClarcq on 11 May 2020
Following the notice that GUIDE will be removed from MATLAB by the end of 2020, I started developing my new projects using App Designer. To put it mildly, it's been a tough journey so far. A number of capabilities in GUIDE are not working in App Designer.
I am facing some challenges specifically on getting the UITable to work for me. The following are my specific issues:
  1. Multiple cell selection using "CTRL+ mouse click" used to be by default in GUIDE. How can I do same in App Designer? I need to programatically get the index of the selected cells.
  2. Range selection using mouse drag used to be by default in GUIDE. How can I do same in App Designer? I also need to get the index of the selected cell ranges.
These are my issues for now.

  1 Comment

Sign in to comment.

Answers (1)

Mohammad Sami
Mohammad Sami on 24 Apr 2020
I have no answer for your first question.
For the second question, I was able to do range selection using left click and dragging the mouse in R2020a.
% quick test
b = randi([1 10],10,10);
b = array2table(b);
f = uifigure;
t = uitable(f);
t.Data = b;
t.CellSelectionCallback = @(~,event)disp(event);
% the event object has the following properties
%CellSelectionChangeData with properties:
% Indices: [8×2 double] first column is row number, second column in column number
% DisplayIndices: [8×2 double]
% Source: [1×1 Table]
% EventName: 'CellSelection'


Mohammad Sami
Mohammad Sami on 24 Apr 2020
For more information on the supported selection options, please see the documentation of CellSelectionCallback for your version of matlab.
Further to my answer, it list all the currently available options for Contiguous Selection Options and Discontiguous Selection Options.
JClarcq on 11 May 2020
Current method of selecting discontinuous cell is totally non-obvious to most users.
"Then, Ctrl+click to focus another cell, and finally Shift+click to select the cell that is in focus"
Even if I know this behavior, this is really unnatural to me. Users are mostly expecting an Excel like behavior which would be:
click to focus cell, Ctrl+click to select, ctrl+shift+click, to select discontinuous groups of continous cells

Sign in to comment.