MATLAB: Using a JTable, is it possible to move the cursor (highlighted cell) horizontally when pressing enter

cursorcursor movementhighlightedhighlighted celljtablemotionmotion on entermotiononentermtablescrollscrollpaneuitable

Hello all,
I was wondering if it was possible, in the underlying java of the uitable, to move the cursor (or highlighted cell) to the next column over (or horizontally) instead of vertically when the user hits enter?

Best Answer

Answered my own question. After examining the jtable properties view (for the millionth time) by using 'get(jtable)' I found a setting called "MotionOnEnterDirection." This allows the user to change what direction the cursor moves whenever the user hits the enter key. The 'get(jtable)' seen below is only a fraction of what is normally seen. I just deleted large chucks to save space. Just wanted to give anyone looking at this a good start point to find the "MotionOnEnterDirection" setting.
>> get(jtable)
MaximumSize: [1x1 java.awt.Dimension]
MiddleSelectionEnabled: 0
MinimumSize: [1x1 java.awt.Dimension]
Model: [1x1 javax.swing.table.DefaultTableModel]
MotionOnEnter: 1
*MotionOnEnterDirection: 0*
Name: 'UiTablePanelTable'
NextFocusableComponent: []
Opaque: 1
OptimizedDrawingEnabled: 1
PaintingForPrint: 0
I simply made a function that fires on a toggle button:
%%--- Executes on button press in btResetSQLInfo.
function btScrollToggle_Callback(hObject, eventdata, handles) %#ok
% hObject handle to btScrollToggle (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mtable = get(hObject,'userdata');
jtable = mtable.getTable;
if get(hObject,'Value')==1
set(jtable,'MotionOnEnterDirection',1)
elseif get(hObject,'Value')==0
set(jtable,'MotionOnEnterDirection',0)
end
Related Question