If 4 'Filloval'
appear, you must select all 4 ovals. If the same oval is selected 4 times, only 1 oval is selected, so the code should not terminate. However, my current code terminates when selecting the same oval four times.
We created a matrix, and if we click on one oval, we're going to erase the column that corresponds to one oval so that it doesn't end if we press one oval in duplicate.
The problem is that if you click one oval in the (14) matrix to create a (13) matrix, the (13) matrix must be maintained, but it does not.
for mouse = 1 : 4 % mouse 4 click
ShowCursor (0);
SetMouse(xCenter, yCenter*1.9, windowPtr);
click = 1;
while click == 1;
[xMouse, yMouse, buttons] = GetMouse(windowPtr);
inside1 = IsInRect(xMouse, yMouse, Tchoicecenter);
inside2 = IsInRect(xMouse, yMouse, Tchoicecenter2);
inside3 = IsInRect(xMouse, yMouse, Tchoicecenter3);
inside4 = IsInRect(xMouse, yMouse, Tchoicecenter4);
if inside1 == 1
Rectlocation(:,mouse) = Tchoicecenter;
if any(buttons)
break
end
elseif inside2 == 1
Rectlocation(:,mouse) = Tchoicecenter2;
if any(buttons)
break
end
elseif inside3 == 1
Rectlocation(:,mouse) = Tchoicecenter3;
if any(buttons)
break
end
elseif inside4 == 1
Rectlocation(:,mouse) = Tchoicecenter4;
if any(buttons)
break
end
end
Tovalcenter = CenterRectOnPoint(ovalBaseRect, TXpos, TYpos);
Tovalcenter2 = CenterRectOnPoint(ovalBaseRect, TXpos2, TYpos2);
Tovalcenter3 = CenterRectOnPoint(ovalBaseRect, TXpos3, TYpos3);
Tovalcenter4 = CenterRectOnPoint(ovalBaseRect, TXpos4, TYpos4);
Screen('FillOval', windowPtr, TColor, Tovalcenter);
Screen('FillOval', windowPtr, TColor, Tovalcenter2);
Screen('FillOval', windowPtr, TColor, Tovalcenter3);
Screen('FillOval', windowPtr, TColor, Tovalcenter4);
end
mouseans = [1:4 ; inside1 inside2 inside3 inside4];
a = find(mouseans(2,:) == 1); % mouse click (True == 1)
mouseans(:,a) = []
end
My current result:
mouseans = 1 3 4 % 2 oval click
0 0 0
mouseans = 1 2 3 % 4 oval click
0 0 0
mouseans = 1 2 4 % 3 oval click
0 0 0
mouseans = 2 3 4 % 1 oval click
0 0 0
The desired result:
mouseans = 1 3 4 % 2 oval click
0 0 0
mouseans = 1 3 % 4 oval click
0 0
mouseans = 1 % 3 oval click
0
mouseans = [] % 1 oval click
How can I click all four ovals without the program terminating?