You cannot "call" the callback function. Callback functions are event-driven, and therefore only triggered when the corresponding event occurs. What you want to do it to create a "central" variable that both callback function can access. So whenever a callback is executed, it will write the required value to the "central" variable, which other callback can also access anytime. The given image describe the scheme. Fortunately, every graphic object has a property called UserData which is there for the user to save data inside the graphics object handle. MATLAB itself never uses UserData property. In your case, you can use UserData property of figure object to save the values of selected cells. A general sketch to do this is
function CBuitable1(HObj, event)
selectedCellTable1 = event.Indices;
try
selectedCellTable2 = HObj.Parent.UserData.table2;
catch
selectedCellTable2 = [];
end
HObj.Parent.UserData.table1 = selectedCellTable1;
end
Similarly, for the second uitable, do it like this
function CBuitable2(HObj, event)
selectedCellTable2 = event.Indices;
try
selectedCellTable1 = HObj.Parent.UserData.table1;
catch
selectedCellTable1 = [];
end
HObj.Parent.UserData.table2 = selectedCellTable2;
end
Using this mechanism, you can share variables among several callbacks.
Best Answer