如何解决多次单击鼠标
如果出现4个'Filloval'
,则必须选择所有4个椭圆。如果选择相同的椭圆4次,则仅选择1个椭圆,因此代码不应终止。但是,当我选择四个相同的椭圆形时,我当前的代码终止。
我们创建了一个矩阵,如果单击一个椭圆,我们将擦除与一个椭圆对应的列,这样,如果一式两份地按一个椭圆,它就不会结束。
问题在于,如果在(14)矩阵中单击一个椭圆以创建(13)矩阵,则必须保持(13)矩阵,但不是。
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,Tchoicecenter);
inside2 = IsInRect(xMouse,Tchoicecenter2);
inside3 = IsInRect(xMouse,Tchoicecenter3);
inside4 = IsInRect(xMouse,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',Tovalcenter2);
Screen('Filloval',Tovalcenter3);
Screen('Filloval',Tovalcenter4);
end
mouseans = [1:4 ; inside1 inside2 inside3 inside4];
a = find(mouseans(2,:) == 1); % mouse click (True == 1)
mouseans(:,a) = []
end
我当前的结果:
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
所需结果:
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
如何在不终止程序的情况下单击所有四个椭圆形?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。