Setting mouse position is triggering button.isClicked()

PsychoPy version: v2022.2.4

I want to implement a task, that is started by pressing a button. The cursor is then set to a specific starting position on screen and a “goal” button appears on the other half of the screen. When bt_goal is clicked, the task ends.

However: The instant I click on the “start” button, the “goal” button registers a button press as well.

I added 2 buttons: “bt_start” and “bt_goal”.
bt_start has callback function with the following python code:

print("bt_start clicked")
trial_started = True
mouse.setPos([0, 0])

bt_goal has its starting condition set to the variable trial_started:

In addition there is one mouse component and one code component.
The code component only sets the variable trial_started at the beginning of the routine to false.

As I mentioned, the moment I press bt_start, bt_goal also registers a click. This does not happen when I change the starting condition of bt_goal to a time (instead of a condition). This does also not happen when I don’t set the mouse position. This does also not happen for all positions I set the mouse to ([0.2, 0] is fine for example). The position I set the mouse to is never within bt_goal.

Is there anythin I dont see or is this a bug?

untitled.psyexp (12.8 KB)

Thanks for making a nice minimally working demo of this bug!

The issue here is that the second button appears in the same location as the first one and that it isn’t using only “new” clicks (which is a bug we are aware of)

One work around is to only present the next button once the mouse key is “lifted” again - here is a demo for that.

untitled.psyexp (12.9 KB)

Hi Becca,

thanks for your reply!

But are you sure though? Because in (my) minimal example the two buttons are placed in different locations ([0, 0.4] and [0, -0.4]) and do not overlap.

And if it was this specific bug, these solutions should not work:

BTW: Thank you guys for all the help here in the forums :slight_smile:

Hi There,

Actually in your minimal demo when I ran it it ran as expected (the second button appeared after the first and in a different location) - so perhaps I had misunderstood that the problem only occured when they are in the same location? Does the attached demo work for you as expected?



your demo works. However you made some changes to it: You do not set the mouse position (mouse.setPos([0, 0])) in the call back func of bt_start.
When I reintroduce this line of code it still works, though.

I don’t think this behaviour is the bug you describe (same location of the two buttons), because the two buttons are not in the same place and the mouse is not set to the location of the second button.

Tbh, I dont know what to do, when you cannot reproduce the error I am having with my minimal example, lol.

My inkling would be that this bug you describe is an offshoot of the one the python team have fixed for the new release. For your current task if my solution works can you use my approach as the solution?