I needed to implement the Button class for the touchscreen. (Do not use a ready-made solution) (The question is not tied to a specific platform, only the principle is interested)
As an Android user, I, of course, understand that if just tracking a touchDown hit on a button and activating it onClick by touchUp is not an option. The user can put his finger on the button, then change his mind and move it. He will raise it no longer within the borders of the button, but it will still click.
You can additionally track that the touchUp was also produced within the boundaries of the button. But it is still not very convenient for the user when the button is large.
Then, having a little libgdx libgdx button implementation, I found something like tap square . As I understand it, this is something like a square around the point where the user clicked. If he raised his finger within the boundaries of the box && within the borders of the button, then the click passes. Well, it's logical.
The easiest way to track the distance between the point at which the user pressed the button and the point at which he raised his finger. If this distance is less than the maximum, then call onClick . Then how to adjust the distance? And after all it needs to be configured not just in pixels, but taking into account dpi ? My version seems to be fine with me, but I would like to know if this is usually done in this way, or am I missing something?
Links are welcome.
onClickListener? Did you read the question? I ask not how to use something ready on the droid, but how it is implemented - selyaМне понадобилось реализовать класс Button для сенсорного экрана. Do you know what is "implement"? I need to make a button for the engine, I'm interested in how it is done in different frameworks, for example, the defaultButtonin Android, or theButtoninlibgdx. - selya