How can I go to the next cell in an UITable in app designer by pressing "intro" or "tab"?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Matt
il 25 Ott 2023
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
il 26 Ott 2023
Modificato: Jonas
il 26 Ott 2023
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.
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!