Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

How to create a hover effect for Mousetrap buttons?

Hi guys,

I'm using the Mousetrap plugin to create 10-choice screen for an emotion recognition task. One thing that I can't figure out is if there is a way to create a hover effect for the buttons - so when someone hovers with the mouse over a button the background and text color are changed.

Is there some way to do this customization in Python?

Thanks,

Ivaylo

Comments

  • HI Ivaylo,

    Yes that is possible. The details depend a little on your specific experiment, but the basic idea looks like that:

    1) Show default image

    2) Enter a while loop

    2.1)sample current mouse position & determine whether it has moved

    2.2. If it hasn't moved for a long enough time (threshold depending what you want), get the current position and determine whether it is located somewhere, where a pop up would make sense.

    2.3. If yes, either draw a new item to the default image (if you havent prepared all the images already,) and show the new image.

    2.4. As soon as the mouse moves, show the default image again.


    Does this make sense?


    Eduard

  • Hover effects are currently not implemented in mousetrap so I think that Eduard's approach makes the most sense. A similar strategy using mousetrap could be (copied and adapted from Eduard's post):

    1) Create and show default canvas

    2) Enter a while loop

    2.1) Use Python version of mousetrap_response item (see this example) and specify the buttons and that no click is required to indicate response

    2.2.) If response has been given (i.e. cursor was moved to one of the specified buttons), modify the corresponding text on the button and show a new item to the default image (if you havent prepared all the images already,) and show the modified canvas.

  • edited April 4

    Thanks, guys! I think this should work in my case. I'll try and post my results here.

Sign In or Register to comment.