How to deselect cells in uitable / how to disable cell selection highlighting?

后端 未结 2 2025
离开以前
离开以前 2021-01-12 15:03

I created the following uitable:

\"bug\"

actually every single row is an indpendent

2条回答
  •  被撕碎了的回忆
    2021-01-12 15:40

    After some deeper research I found out, that the Matlab Support comes out with the following solution:

    %overwrite data with a dummy and restore the old data afterwards, to force deselection
    function modifySelection(src,~)
     ...
    temp = get(src,'Data')
    set(src,'Data',{ 'dummy' });
    set(src,'Data', temp );
    
    end
    

    Doing this the blue highlighting is gone, BUT the dotted line around the last selected cell remains! But I found a solution resolving this, which also makes the first part dispensable.

    function modifySelection(src,evt)
     ...
    fh = get(src,'parent');    % get parent figure handle
    copyobj(src,fh);           % copy uitable to parent figure
    delete(src);               % delete current uitable
    
    end
    

    Which results in the desired behaviour:

    enter image description here

    Drawback of the second solution: it lags a little (probably just on slow machines), because of the creation of a new object.

提交回复
热议问题