uitable autofill without cursor jumping to cell (1,1)
5 views (last 30 days)
I've made a gui where I have a uitable that should take the users input an paste it into another cell, for example:
What is in cell(1,2) should be pasted into cell(2,1), and cell(2,2) pasted into cell(3,1) and so on.
I've used this answer to write my code.
function uitable1_CellEditCallback(hObject, eventdata, handles)
table = get(handles.uitable1,'data');
Depth_data = table(:,2);
for h = 1:size(table,1)-1
table(h+1,1) = Depth_data(h);
It does what it is supposed to do, but this is where I have an irritating error, when I enter values the cursor or tab jumps to cell(1,1), so I cant just press enter and it jumps to the next cell, how do I fix this? Is there a way to store where the cursor is and then make it jump back to that cell or the next instead of jumping to cell(1,1) all the time?
Jan on 15 May 2018
Edited: Jan on 18 May 2018
Perhaps this helps: https://www.mathworks.com/matlabcentral/answers/348905-programatically-selecting-cells-in-a-uitable
[EDITED] Code suggested in this thread:
jUIScrollPane = findjobj(handles.uitableHandle);
jUITable = jUIScrollPane.getViewport.getView;
jUITable.changeSelection(row-1, col-1, false, false);