Button.LongClick triggers also Button.Click event / bug

If you perform a Button.LongClick, the Button.Click event is always triggered as well.
This is a bug. @ewpatton

buttonLongClickEvent_bug.aia (15.2 KB)

(Precisely, the Button.Click event is triggered after a Button.LongClick when Button.TouchUp, see the gif-Animation below.)


It might be - or it might be a limitation. you will see this occur across others (unrelated to App Inventor/Java/Scheme) as well. Usually, it doesn't actually matter.

That's not evidence of a bug, as I said before - some languages have been around far far longer that App Inventor :grin: and you will find this idiocracy there. I'm not saying that what might be expected would not be desired, but I am saying most times it is not important (does not matter) and it could be a challenge to change.

Obviously not, as I showed using @Ken's extension.

That looks very nice!

I noticed this error a long time ago. I don't remember solving it, but using the flag I guess. But if it worked as it should, it would be great.

I think it might be that the developer was thinking more OR than AND or yes indeed possibly was a developer oversight but until now nobody expressed concern. However, it is now apparently the most important issue that AI2 has ever had, so I have put it in the hands of Evan Patton. :owl:

No, it's just a simple side note. But a bug.

I don't think this is a bug. It is designed to do so, as shown in the source of ButtonBase.java

This is what I understand from my own perspective.

And also, according to this link:

If the override method return false, it will also trigger the click event.

Yes of course, you can just do it like this:

But shouldn't it be possible to do this without an additional variable?

From your link I understood that it returns "false" from long click if we don't want to handle long click?
So someone would have to change from "return false" to "return true".

Actually, a long click is also a kind of click when component was clicked longer than a normal click. :sweat_smile:
It is default behaviour of android.
Once I made a home button click listener extension.
But when I long clicked the home button it fired the Click event also.

Yes, we know this, but it shouldn't.
Btw, if you make a long click, the Button.Click event is triggered after Button.TouchUp (as I've alread shown).

Now I corrected it.Probably you mistunderstood physical home button with a button component.

Then correct order should be this:
When click happens
Touch down > Click > Touch up

When Long Click happens
Touch down > Click > Long Click > Touch up

No, the order for a long click is:
TouchDown β†’ longClick (event triggered) β†’ TouchUp β†’ Click (event triggered)

1 Like

Yes, that's why I said the correct order should be

but it is not same here as you said that order here is

Ok, the order should be:
TouchDown β†’ longClick (event triggered) β†’ TouchUp β†’ (nothing is triggered / happened)

1 Like

Yes, but still Click event should be triggered before Long Click event.

No, why should it?