Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!b38g2000prf.googlegroups.com!not-for-mail
From: SLt <stephanie.lescarret@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: uitable - checkbox column callback
Date: Wed, 15 Oct 2008 00:55:55 -0700 (PDT)
Organization: http://groups.google.com
Lines: 60
Message-ID: <723eb209-547f-433a-9bdc-569ebb1d63e9@b38g2000prf.googlegroups.com>
References: <gd3okl$i47$1@fred.mathworks.com>
NNTP-Posting-Host: 86.66.90.231
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1224057355 14606 127.0.0.1 (15 Oct 2008 07:55:55 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 15 Oct 2008 07:55:55 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: b38g2000prf.googlegroups.com; posting-host=86.66.90.231; 
	posting-account=2_yMqQoAAACcKhEndhXKnyqwk2rpxgyI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.12) 
	Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:495262


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