-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Events are delivered twice to "on event from" handler with value MICROBIT_EVT_ANY #2382
Comments
This could be regression caused by the fix for #1334. When fixing this one we should double-check the other test case as well. Btw, I tested on a device and see a different (wrong) behavior in step 4: |
Thanks for confirming @philipphenkel . That is what I see when I press and release, but I left out the details! A quick press-release will be 1,2,3 (down,up,click) or a long press and release will be 1,5,2 (down,hold,up). Each of these events is delivered twice for MICROBIT_EVT_ANY but only event 1 is comparable with the MICROBIT_BUTTON_EVT_DOWN case. I think it's any event too, not just the buttons. I was trying to use the gamepad events. |
This could be a duplicate of #2255 (see #2255 (comment) for a generic test example) |
Yes @philipphenkel . This looks like the same or very closely related problem. |
I think the problem lies in incompatibilities in various versions of findBinding and dispatchEvent. See microsoft/pxt-common-packages@1167fa3 The action of findBinding has been changed to return the ANY binding as well as the requested one, with the addition of a nextBinding function and insertion of the old findBinding implementation into setBinding. The implementations of dispatchEvent in pxt-common-packages have been changed to use the new findBinding and nextBinding, but the implementation of dispatchEvent in pxt-microbit assumes the old findBinding behaviour. It tries to find the specific binding then the ANY binding, but will find the ANY binding twice unless the specific one is first in the list (defined last). |
Describe the bug
When using an "on event from" handler with value MICROBIT_EVT_ANY, each event is delivered twice.
Tested using Button A events and MES_DPAD events.
Occurs on live and beta but not on v1.
In addition, the simulator shows the wrong events for button A presses..
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Each event should be delivered just once each time it is sent.
Desktop (please complete the following information):
Live
makecode.microbit.org version: 2.0.6
Microsoft MakeCode version: 5.15.12
microbit runtime version: pxtgc-0
And beta
makecode.microbit.org version: 2.1.4
Microsoft MakeCode version: 5.19.8
microbit runtime version: pxtgc-0
The text was updated successfully, but these errors were encountered: