MATLAB Answers


Removing uitable cell selection highlight

Asked by Jim
on 14 May 2013


I have a uitable that includes a checkboxes in column 1 and string-valued entries in column 2. Some of the entries may be "ghosted", which is faked by prepending HTML tags to change their font color to gray. A corresponding bitvector keeps track of the ghosted rows. Clicking in either column on a ghosted row is ignored, with an immediate return from the CellSelectionCallback routine.

This works OK except for one annoyance: When a ghosted string (column 2 of a ghosted row) is clicked, the blue cell selection highlight remains on after the return from the callback. A subsequent click in column 1 of the same row, will remove it, but that's not a good solution. Can anyone suggest a way to programmatically remove it ("deselect" the clicked cell)?

BTW, I just purchased Yair Altman's excellent book Undocumented Secrets of MATLAB-Java Programming, but this doesn't seem to be a covered topic.




No products are associated with this question.

2 Answers

Answer by Yair Altman
on 18 May 2013
 Accepted answer

This is covered (briefly) at the bottom of page 169 of my book...

  1 Comment

on 20 May 2013

Yes, I see it now. Thanks.

Mathworks also gave me a pure Matlab work around to fix this, which is to set the Data property of the uitable to some temporary value, and then restore it to its original value prior to returning from the cell selection callback. The temporary value must be different from the original to force the deselection.

Answer by Walter Roberson
on 14 May 2013

You could try setting the uitable to 'enable' 'off', drawnow(), then 'enable' 'on' and drawnow()

  1 Comment

on 15 May 2013

Walter, Thanks for the suggestion, but unfortunately that doesn't work. I've also tried a plain drawnow() without toggling the enable property, and a figure() call. No joy so far. -Jim

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!