uitable
:
实际上,每一行都是一个独立的uitable
,所以展示的表格除了表头外包含5个uitable
。我这样做的原因是我的上一个问题,导致显示的表格。你可以在这里找到完整可执行代码(或下方提供的最小化示例)。使用通用GUI的解决方法也在那里,但这会使代码过于复杂,实际上它似乎只是一种错误。可以看到,每当我跳转到下一行,也就是另一个
uitable
时,上一次的选择仍然保持高亮状态,看起来很愚蠢,尽管这对功能不重要。
'SelectionHighlight'
属性适用于uitable
,听起来像是解决办法,但是它并没有改变任何东西。我如下使用它:set(src,'SelectionHighlight','off') %where src is the handle of the current uitable
在多个地方使用:在 'CellSelectionCallback'
的末尾,在 'CellEditCallback'
的末尾以及作为全局属性。 但是每次最后一个单元格都保持选定状态。 实际上,我根本不需要选择。
如何禁用所有uitables的整个选择或选择突出显示属性?
我应该如何使用此属性才能产生效果?
或者:如何更改“突出显示”的颜色(因此文本颜色)使突出显示不再可见?
显然,这个问题也出现在其他情况中。
我创建了一个最小可执行示例,在其中可以在每行中选择1到3个数字。
function minimalTable
%basic properties
line_height = 21.32;
table_height = 3*line_height;
lh = line_height/table_height;
h = figure('Position',[200 100 202 table_height],'numbertitle','off','MenuBar','none');
% addrow(figurehandle,number of row, percentage lineheight)
% every function call creates a new row, later dynamically
addRow(h,1,lh);
addRow(h,2,lh);
addRow(h,3,lh);
end
function modifySelection(src,~)
set(src,'SelectionHighlight','off')
waitfor(src)
end
function [th] = addRow(fh,k,lhp)
selector = { '1'; '2' ; '3' };
defaultData = {'select number...'};
columnformat = { {selector{:}} };
columneditable = true;
th = uitable(fh,'Units','normalized','Position',[0 1-k*lhp 1 lhp],...
'Data', defaultData,...
'ColumnName', [],...
'ColumnWidth', {200},...
'ColumnEditable', columneditable,...
'ColumnFormat', columnformat,...
'RowName',[],...
'SelectionHighlight','off',...
'CellEditCallback',@modifySelection);
end
导致结果: