Button.LongClick triggers also Button.Click event / bug

Actually I said

it works fine in my project

I disagree, it all serves to clarify the issue.

As I said, there was really no need to restart the discussion from the beginning.

I disagree, it was not clear where the problem lay in your original post, because you supplied so many different methods.

1 Like

Yes, and it is triggered after 400-403ms.

Blocks

buttonLongClick2.aia (3.6 KB)

1 Like

@Anke is right.

1 Like

So, this is the answer.

1 Like

No you said

"I have just tested → it".
You should have said "I have just tested → something"

@Anke, I have a strange situation in my sample app. Why does it work without additional flags, even though previous tests indicate an error. Could you take a look at this? All click events are successful.

I know the topic is old. The AI2 update is coming. I think a fix could be made to prevent the click event from being raised when long clicks. Since each click method has its own event, this can be separated.

From little experience, and from the description itself, it appears that it is enough to change from "return false;" to "return true;" in ButtonBase.java.

public abstract void click();

  // Override this if your component actually will consume a long
  // click.  A 'false' returned from this function will cause a long
  // click to be interpreted as a click (and the click function will
  // be called).
  public boolean longClick() {
    return false;
  }

  // OnClickListener implementation

  @Override
  public void onClick(View view) {
    click();
  }

The "fix" is simple, the problem has always been the fact that apps may have functionality that would be affected semantically by this change, effectively breaking them without a way to address it. A more complicated solution would involve having a property on the button to control the expected behavior.