Search code examples
matlabuser-interfacecallbackmatlab-figurematlab-uitable

How do I make the matlab-uitable CellSelectionCallback respond to multiple consecutive clicks in the same cell?


--UPDATE--

I discovered that the uitable does not register a 'second click' when t.ColumnEditable = true. When this is true, MATLAB waits until you personally deselect the cell to begin registering new clicks. Hence, that entire time it expects that new clicks are edits to the cell. Turn t.ColumnEditable to false and consecutive clicks register as new actions.

--

The CellSelectionCallback only seems to register clicks in new cells. For example, the following only displays 'src' and 'event' during the first click to any particular cell:

close all;
f = figure('Position',[50,62,1340,326],'Units','pixels'); % set figures so they're stacked
f.Name = 'Debugging table';
t = uitable(f,'Units','normalized','Position',[.05,.05,.9,.9]);
t.CellSelectionCallback = @cellSelected;
t.ColumnName = {};
t.RowName = {};
t.Data = magic(10);
t.FontSize = 10;
t.FontName = 'AppleGothic';
function [src,event] = cellSelected(src,event)
    src
    event
end

Can anyone provide a method that branches off of something like this that would allow the code inside 'cellSelected' to run on more than one consecutive click to a single cell in the active uitable? Thanks in advance.


Solution

  • --UPDATE--

    I discovered that the uitable does not register a 'second click' when t.ColumnEditable = true. When this is true, MATLAB waits until you personally deselect the cell to begin registering new clicks. Hence, that entire time it expects that new clicks are edits to the cell. Turn t.ColumnEditable to false and consecutive clicks register as new actions that independently trigger the cellSelected callback function.

    --