Path: news.mathworks.com!not-for-mail
From: "Nick Denman" <ngdenmanNOSPAM@gmail.REMOVETHIS.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: uitable - checkbox column callback
Date: Fri, 17 Oct 2008 00:41:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 67
Message-ID: <gd8muu$leq$1@fred.mathworks.com>
References: <gd3okl$i47$1@fred.mathworks.com> <723eb209-547f-433a-9bdc-569ebb1d63e9@b38g2000prf.googlegroups.com>
Reply-To: "Nick Denman" <ngdenmanNOSPAM@gmail.REMOVETHIS.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1224204062 21978 172.30.248.37 (17 Oct 2008 00:41:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 17 Oct 2008 00:41:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 745609
Xref: news.mathworks.com comp.soft-sys.matlab:495723


SLt <stephanie.lescarret@gmail.com> wrote in message <723eb209-547f-433a-9bdc-569ebb1d63e9@b38g2000prf.googlegroups.com>...
> On Oct 15, 5:39 am, "Nick Denman"
> <ngdenmanNOS...@gmail.REMOVETHIS.com> wrote:
> > 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',[]);
> 
> Hi
> 
> I've already code something like that. But instead of using a data
> application and setappdata to know if your are in the callbak or not,
> I reset the DataChangedCallback. And i was often forced to add some
> pause in order Matlab to take in account the reset.
> 
> 
> function checkboxCallback(mtable,eventdata)
> 
> % Reset the DataChangedCallbak
> set(mtable, 'DataChangedCallback', '');
> 
> pause(0.1) % To be sure the DataChangedCallback was changed
> 
> % Make change using setValueAt
> ...
> 
> pause(0.1) % To be sure the setValueAt are finished
> 
> % Set the DataChangedCallback
> set(mtable, 'DataChangedCallback', @checkboxCallback);
> 
> 
> It's not very pretty but it works ...
> 
> SLt

Hi SLt

Thank you for your suggestions. Unfortunately, it didn't fix the problem (now the callback is not firing) as I don't believe that the DataChangedCallback is being re-enabled during the call to the callback function.

Cheers, Nick