Allowing backspace only on the last item entered
Mostra commenti meno recenti
Hi, I've been having trouble figuring out how to allow backspace only on the last item entered. I was trying to modify some codes on the psychtoolbox function 'GetEchoString'. In this function, it allows backspacing for all items entered:
string = '';
while true
char = GetChar;
switch (abs(char))
case {13, 3, 10}
% ctrl-C, enter, or return
break;
case 8
% backspace
if ~isempty(string)
string = string(1:length(string)-1);
end
otherwise
string = [string, char ' '];
end
But I just want to allow backspacing only on the last item entered. (i.e.: case 8 cannot be entered twice in a row).
How do I do that?
Thanks in advance!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Image display and manipulation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!