|
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
|