How do I get the position of a call when I select it in a uitable? I know you can associate a CellSelectionCallback with a table, but what is the property to pull? A similar question two years ago said the proper field is Indices but this doesn't seem to work for me (Note, I am using R2008a). I would be expecting get(t,'Indices') to do the trick for me (t is the table), but such a field isn't recognized.

 채택된 답변

Walter Roberson
Walter Roberson 2011년 5월 13일

0 개 추천

The CellSelectionCallback will be passed a minimum of two parameters, the first of which will be the uitable handle, and the second of which is the event data, which people commonly program to be received into the variable named "event". For CellSelectionCallback, event will be a structure which will have one field named "Indices" and it is that you want to look at.
For example,
function GasPricesTable_Selection_CB(src, event)
selected_cells = event.Indices;

댓글 수: 5

Eugene Kogan
Eugene Kogan 2011년 5월 13일
Sorry, but what is the event data and how do you grab it?
Eugene Kogan
Eugene Kogan 2011년 5월 15일
Hello, can anyone clarify this eventdata point? Still haven't been able to get it implemented.
Jan
Jan 2011년 6월 26일
Who did bump this thread and why? Is the question still open?
Walter Roberson
Walter Roberson 2011년 6월 26일
Not sure, Eugene might simply have Accepted the answer: that bumps it.
James Ang
James Ang 2016년 4월 18일
편집: James Ang 2016년 4월 18일
This solves my problem.... maybe it'll help some of you guys..
1) right click on the table, select 'CellSelectionCallback'. An automated function will be generated for you (displayed in the property Inspector - also right click the table to select).
E.g mine is "@(hObject,eventdata)NmodeDataRead_v10('data_uitable_CellSelectionCallback',hObject,eventdata,guidata(hObject))'"
2) This function will be added to your codes.
function data_uitable_CellSelectionCallback(hObject, eventdata, handles)
% hObject handle to data_uitable (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) currently selecteds
% handles structure with handles and user data (see GUIDATA)
% disp(eventdata)
handles.datatable_row = eventdata.Indices(1);
handles.datatable_col = eventdata.Indices(2);
guidata(hObject, handles);
Just add the lines of codes above to get the indices...
hope this helps.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2011년 5월 13일

편집:

2016년 4월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by