I am using GUIDE in MATLAB R2012b, and have a uitable
with editable logical checkboxes. The Cell Edit callback is as follows:
function data_table_CellEditCallback(hObject, eventdata, handles)
row = eventdata.Indices(1);
column = eventdata.Indices(2);
if column ~= 1 % The checkboxes are all in the first row.
guidata(hObject,handles);
return;
end
table_data = get(hObject,'Data');
if table_data(row,column) == true
table_data(row,column) = false;
else
table_data(row,column) = true;
end
set(hObject, 'Data', table_data);
handles.checked(row) = table_data(row,column); % Variable holding the data.
guidata(hObject,handles);
end
When I click one of the checkboxes, I can see that the data in the table gets appropriately updated (both get(hObject,'Data')
and handles.checked(row)
return the updated value), BUT the actual checkbox in the GUI does not visually become checked. If I click it again, the variables are again updated, but the checkbox remains unchecked.
So the data is being updated, but the GUI is not. What is going wrong here?
Note: The logical checkboxes are set to editable in GUIDE, so this is not the problem.