Using latest PTB, Windows 10/OS 12.7, Matlab 2023b
Hi all,
I’m using the HideCursor/ShowCursor functions and they work just fine on my macbook, but not on windows. HideCursor works fine, but when I call ShowCursor the cursor doesn’t pop back up-- instead, I can only see it contrasted negatively against drawn objects (like a fixation point, drawn dots) and it completely disappears against the background. I tried using a small debugging window and for reason the transparent cursor suddenly becomes visible when I move to the matlab window and then back onto the ptb window. I’ve tried indicating which window to display in ShowCursor to no avail. Any thoughts? This is the relevant code:
%Window
Screen('Preference', 'SkipSyncTests', 1)
screens = Screen('Screens');
screenNumber = max(screens);
black = BlackIndex(screenNumber);
white = WhiteIndex(screenNumber);
gray = white/2;
[window, windowRect] = Screen('OpenWindow' , screenNumber, gray);%, [0,0,200,250], [], [], [], [], [], kPsychGUIWindow);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
[xCenter, yCenter] = RectCenter(windowRect);
ifi = Screen('GetFlipInterval', window);
HideCursor(window);
SetMouse(xCenter, yCenter, window);
Screen('BlendFunction', window, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
% Setup window text type
Screen('TextFont', window, 'Ariel');
Screen('TextSize', window, 25);
%Fixation Stuff
fixCrossDimPix = 8;
xCoords = [-fixCrossDimPix fixCrossDimPix 0 0];
yCoords = [0 0 -fixCrossDimPix fixCrossDimPix];
allCoords = [xCoords; yCoords];
lineWidthPix = 5;
%Radius size in pixels for cir cle whose circum stims center on
arc1Rad = 250;
arc2Rad = 350;
%Timing
prac1Counter = 1;
prac2Counter = 1;
pracStop = 2;
%Instructions
DrawFormattedText(window,['On each trial, you will be presented with a single white dot. \n\n' ...
'Remember where the dot was located. \n\n' ...
'When the cross turns red, simply click the screen at the location you remember the dot was. \n\n' ...
'Press Space to Start'], 'Center', 'Center', white);
Screen('Flip', window);
KbStrokeWait;
Screen('Flip', window);
DrawFormattedText(window,['The following will be practice trials \n\n'...
'Press Space to Start'], 'Center', 'Center', white);
Screen('Flip', window);
KbStrokeWait;
Screen('Flip', window);
while prac1Counter <= pracStop
%CALCULATIONS
%Formula for finding (x,y) for object on arc 1
%Each theta is a set of angles for each quadrant
%Randomly select an angle in the middle 30* of selected quadrant
quad = randsample(1:4,1);
if quad == 1
thetaArc = randsample(30:1:60,1);
elseif quad == 2
thetaArc = randsample(120:1:150,1);
elseif quad == 3
thetaArc = randsample(210:1:240,1);
elseif quad == 4
thetaArc = randsample(300:1:330,1);
end
%Do some trig, reset coordinates around center of screen (rather than
%top corner, (0,0) in matlab
xArc = round(arc1Rad .* cosd(thetaArc)) + xCenter;
yArc = round(arc1Rad .* sind(thetaArc)) + yCenter;
%TRIAL SEQUENCE
%Fixation
Screen('DrawLines', window, allCoords, lineWidthPix, black, [xCenter yCenter], 2);
Screen('Flip', window);
WaitSecs(.5);
%Display Object consentKey
Screen('DrawDots', window, [xArc, yArc], 25, [], [], 1);
Screen('DrawLines', window, allCoords, lineWidthPix, black, [xCenter yCenter], 2);
Screen('Flip', window);
WaitSecs(.5);
Screen('Flip', window);
Screen('DrawLines', window, allCoords, lineWidthPix, black, [xCenter yCenter], 2);
Screen('Flip', window);
%Report
Screen('DrawLines', window, allCoords, lineWidthPix, [255,0,0], [xCenter yCenter], 2);
Screen('Flip', window);
SetMouse(xCenter,yCenter);
ShowCursor(1,window);
[click, xMouse, yMouse] = GetClicks(window,[],[],GetSecs+10);
if click == 1
Screen('Flip', window);
HideCursor(window);
xMouse = round(xMouse);
yMouse = round(yMouse);
end
Screen('DrawLines', window, allCoords, lineWidthPix, black, [xCenter yCenter], 2);
Screen('Flip', window);
WaitSecs(1);
%Feedback
Screen('DrawLines', window, allCoords, lineWidthPix, black, [xCenter yCenter], 2);
DrawFormattedText(window,'Your Response', 'Center', yCenter - 50, white);
Screen('DrawDots', window, [xArc, yArc], 25, [], [], 1);
Screen('DrawDots', window, [xMouse, yMouse], 25, [250, 0, 0], [], 1);
Screen('Flip', window);
prac1Counter = prac1Counter + 1;
WaitSecs(2);
end
sca;