Path: news.mathworks.com!not-for-mail
From: "Nick Denman" <ngdenmanNOSPAM@gmail.REMOVETHIS.com>
Newsgroups: comp.soft-sys.matlab
Subject: uitable - checkbox column callback
Date: Wed, 15 Oct 2008 03:39:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <gd3okl$i47$1@fred.mathworks.com>
Reply-To: "Nick Denman" <ngdenmanNOSPAM@gmail.REMOVETHIS.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1224041941 18567 172.30.248.35 (15 Oct 2008 03:39:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 15 Oct 2008 03:39:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 745609
Xref: news.mathworks.com comp.soft-sys.matlab:495227


Hi

I am trying to implement a logic between two columns in a uitable (R2007A - undocumented) where if the checkbox is clicked in one column, the checkbox in the other column is unchecked. I have tried implementing this using the DataChangedCallback and examples from Yair Altman on how to ensure that the callback does not enter an infinite loop. Unfortunately I have not been successful and the two checkboxes continually flicker when one is pressed and the callback does not end.

I have included the function used in the uitable's DataChangedCallback below. The checkbox columns are columns 11 and 12 (java-based index). Any suggestions would be greatly appreciated.

Cheers, Nick

%-----------------------------------------------------------
function checkboxCallback(mtable,eventdata)

if ~ishandle(mtable)
    return;
end

if ~isempty(getappdata(mtable,'inCallback'))
    return;
end

setappdata(mtable,'inCallback',1);

eventDetails = eventdata.getEvent;
col = eventDetails.getColumn;
row = eventDetails.getFirstRow;
if row >= 0 && col >= 11 && col <= 12
    mtable.getTable.setValueAt(true,row,col);
    mtable.getTable.setValueAt(false,row,11+doubl(col==11));
end

setappdata(mtable,'inCallback',[]);