FMX Touch Sensitivity Tip

FMX Android often misses tap events, even if a control gives a visual indication that a tap occurred. This can become frustrating for the user, requiring them to tap two, sometimes three times.

Horizontal Swipe Issue

I had a suspicion that FMX was receiving the touch event correctly, but had problems identifying less precise user gestures. I had a similar issue with swipe left and swipe right, if the swipe is not perfectly horizontal it is not recognized. The problem is in the FMX gesture detection code. Since people swipe on a slight angle, these gestures weren’t detected. Again, very frustrating for the user, as noted on StackOverflow:

I managed to solve the swipe issue by overriding the OnTouch event in the MainForm and detecting a swipe from a minimum series of events.

AppBar Touch Issue

Similar to the swipe solution, if the AppBar’s SpeedButton(s) fail to detect a tap, I manually look for the touch event.

For example, a touch event within Y< 56 and and X < 56 can be used to trigger a back button manually. In Material Design, the back button has margins of 16, and a height and width of 24, from where we get the X and Y values of 56. Given the AppBar has a height of 56, any event with a start or end Y value of less than 56 can reasonably be assumed to indicate the user is trying to tap on the AppBar. The code then delegates to the AppBar which activates the button at position X.

Here’s my MainForm’s OnTouch function which looks for the swipe gesture, and the missed tap:

Note: FStartX is initialized with a value of -999.

I hope this tip helps.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s