pxt-microbit icon indicating copy to clipboard operation
pxt-microbit copied to clipboard

Pressing buttons too long returns nothing after release

Open gomakekit opened this issue 1 year ago • 4 comments

Describe the bug When pressing button A, B or A+B for more than about 3 second, nothing happens. Carlos Pereira told me last week on Bett that might be due to a planned long press that never came into use.

A clear and concise description of what the bug is.

To Reproduce (makecode javascript:)

input.onButtonPressed(Button.A, function () { basic.showString("A") }) input.onButtonPressed(Button.B, function () { basic.showString("B") }) basic.clearScreen() basic.forever(function () {

})

Steps to reproduce the behavior: Press and hold button A for more than 3 seconds

Expected behavior Nothing happens even after releasing the button.

micro:bit version (please complete the following information): I believe it applies to all versions (I am using the V2 micro:bit and latest official makecode)

Additional context Say you have a microbit acting as a remote for a drone or hovercraft. You are instructed to press A + B to start the vehicle. Often people press and hold too long so they don´t get to start it. We have to tell them "To quickly press and release A+B" which is less practical.

It would be much better if the key press resulted in immediate action as soon as the key was pressed (not upon release), or at least upon release but no matter how long it was hold.

Or: Enabling long press for buttons A, B and A+B, which would give a lot more options.

Currently, there seems to be no option for a long press event (see screen shot)

Screenshot 2024-01-30 at 16 10 35

gomakekit avatar Jan 30 '24 15:01 gomakekit

This is a candidate for extension.

abchatra avatar Feb 15 '24 18:02 abchatra

There is the button clicks extension https://makecode.microbit.org/pkg/bsiever/microbit-pxt-clicks

Or LONG_CLICK is 4 and HELD is 5 https://makecode.microbit.org/_bF2Xk7MmmazR

The list is here:-

https://github.com/lancaster-university/codal-core/blob/63f017fdcd12aca769264c36fe47e6071a40e502/inc/driver-models/AbstractButton.h#L35

https://github.com/lancaster-university/microbit-dal/blob/e5b67417d4dc6b01bc369d89bb1525fc7a9575c9/inc/drivers/MicroBitButton.h#L41

martinwork avatar Feb 15 '24 20:02 martinwork

I think there are two different parts to this:

  1. We have a long press event and an extension to use it
  2. Because of the long press feature, when a user presses a button for too long the "normal" press event is not triggered.

We can leave the long press blocks as an extension, but 2) is probably a bug that needs consideration.

microbit-carlos avatar May 01 '24 16:05 microbit-carlos

I agree completely, when there is no long press extension at play, you shouldn´t be held back for holding a bit too long. We have quite a lot of problems with it, especially the A+B, people are holding too long very often (when using micro:bit as a remote)

gomakekit avatar May 08 '24 21:05 gomakekit