dimanche 25 décembre 2016

Typing speed test

I'm doing a GUI project. Something like typing speed test. I mean that you see a line of text and you have to rewrite it as fast as you can. I wonder if there's any option to check in real time if entered char is equal to char in displayed text. I want it to check if the letter I just typed is the same as the letter in displayed text, which I was supposed to type in that moment.

Now my code is not running well, because the for loop is not waiting for me to type anything, it is just checking if default String in edittext is equal to the line of test text displayed above it. I want it to check char by char if it is equal.

I also wanted to mark red the letter you have to type now, but I don't know how to do it.

That's part of my code:

function easy_Callback(hObject, eventdata, handles)
fileID = fopen('lol.txt');
tline = fgetl(fileID);

while ischar(tline)
set(handles.textdisp, 'String', tline);
L = length(tline);
w = waitforbuttonpress;
for i = 1 : L
     if w == 0;
lineKey = get(handles.keyboard1, 'String');
if strcmp(tline(i), lineKey(i)) 
i = i+1;
else 
   disp('error');
end

end
end
tline = fgets(fileID);
end
fclose(fileID);
guidata(hObject, handles);

keyboard1 is edittext in which I rewrite the text above textdisp is a line of text which you have to rewrite

I tried with pause and waitforbuttonpress but it just doesn't work.

Aucun commentaire:

Enregistrer un commentaire