多次单击鼠标

问题描述

如果出现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 (将#修改为@)