How can I go to the next cell in an UITable in app designer by pressing "intro" or "tab"?

23 次查看(过去 30 天)
I am using tables in app designer, but I want to write values into the cell and then i want to press "intro" to jump to the next cell, but it is not possible, so I have to click there in the next cell, which is impractical.
Someone here knows how to program that maybe in an event?
  5 个评论
Matt
Matt 2023-10-25
Hi,
I know this is an old question but i'm curious if this is still the case, it would be great to be able to change the focus using tab/enter (or shift tab/enter) as familiar with moving through cells in Excel. Would definitely be a nice feature to have.
Jonas
Jonas 2023-10-26
编辑:Jonas 2023-10-26
hey @Matt,
I just had a short look into that and i managed to make the possible to navigate using tab, return or with the modifier shift. however it is not possible to (vusially) move the selection back to the first cell you clicked on. I does not highlight, although the position is set correctly.
I do not know why, but all other cells work.
close all hidden;
fig=uifigure;
tableSize=[4,4];
tbl=uitable(fig,'Data',num2cell(rand(tableSize)),'ColumnEditable',[false true true true]);
tbl.KeyPressFcn={@handleButtons,tableSize};
function handleButtons(src,evt,maxSize)
if isequal(evt.Modifier,{'shift'})
direction=-1;
else
direction=1;
end
if strcmp(evt.Key,'tab')
newPos=src.Selection+[0 direction];
elseif strcmp(evt.Key,'return')
newPos=src.Selection+[direction 0];
else
newPos=src.Selection;
end
% prevent over- and undershoot
newPos=min([newPos;maxSize]);
newPos=max([newPos;[1 1]]);
src.Selection=newPos;
drawnow;
end
at the edges of the table, the tab will lead to a unselection of the table, tabbing again will set the focus on the table again. enter at the lower edge of the table will lead to the edit mode.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by