psychopy.org | Reference | Downloads | Github

Changing the cursor into a hand

Dear,

Could someone help me how I can make the cursor a hand when a user hovers over an image?

Your help will be appreciated.

Thanks
Y

You’d have to simulate that:

  1. Create a pair of image stimuli (called mouseStd and mouseHover?) and on each frame set their position to be the mouse.pos (where mouse is created higher up in the same Routine. Set their start/stop times to be the same (eg. t=0 everywhere) so that they don’t get drawn depending on time
  2. Add code like this to a Code Component, to test which one to draw on each frame (let’s say the image you care about was called stimulus:
if stimulus.contains(mouse):
    mouseHover.draw()
else:
    mouseStd.draw()

I think that’s all you need. And then a pair of images for your mouse cursors :slight_smile:

@yuu if that worked could you tick on the “solved” button please? Thanks

You’ll have to tell us what happened when you “failed”. What was the error message?

You need to pay attention to this part of Jon’s instructions:

I did but it is quite unclear for me.

I was confused between ( create a pair of image stimuli (called mouseStd and mouseHover?)) and (let’s say the image you care about was called stimulus).

Any help will be appreciated.

Best

mouseStd and mouseHover refer to the stimuli you need to create that will indicate the mouse position and state. Have you created them? That error will disappear when you do.

But you should also change the code to do just a single check, as they probably contradict each other when done in series:

if pictureLeft.contains(mouse) or pictureRight.contains(mouse):
    mouseHover.draw()
else:
    mouseStd.draw()

Dear m-macaskill,
(mouseStd and mouseHover refer to the stimuli you need to create that will indicate the mouse position and state. Have you created them?)

I think Yes, I did what you have said. Could you kindly see the picture attached?

And I put the same coding and I got the same error message.

Best,

You need to really carefully read the previous messages. Where are your target images? Now you just seem to have two image stimuli, to represent the mouse. Where are the ones that are supposed to be shown on the screen for the person to move the mouse over? And we need to know what they are called.

For some reason, you are using a variable here (e.g. pictureLeft) to represent the image to be shown for the mouse cursor. Instead this should just be the name of a fixed image file for a hand or a pointer.

Dear Michael,

as shown in the reference file (under ‘pictureLeft’ & ‘pictureRight’) in my previous message, picture1 and picture2 are the target images which will be shown on the screen. You can see their original places in the photo attached.

Best,
Yuu

Hi guys,
can I also do that in the builder view? What do I have to enter to get the mouse position for the object on every frame?
Would it be easier to change the mouse settings with custom.mouse? However, I do need to reset it’s position on every repeat and that didn’t seem to work before?

Thanks for any help, just startet working with psychopy…