Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodDelphiFiremonkeyIOSOSXWindows

Listview OnItemClick And Swipe To Delete Event Order In Delphi XE6 Firemonkey On Android

Delphi XE6 Firemonkey Listview Tap Swipe Delete EventsDeveloper Jeff Martin has a comment up on Google Plus where he outlines the event order for tapping on a TListView in Delphi XE6 Firemonkey. The original question by John Fisher was basically how to figure out if the Swipe to Delete button is up or not and how to differentiate between that and a normal tap on a TListView item. The answer is only in regards to Android so it may be different on IOS. The answer probably also applies to AppMethod. Here is the full comment from Jeff:
I just ran a test on Android (with only Left/Right enabled in the gesture set for my ListView). Here's what I found:

With no item currently showing a Delete button; a tap on a non-selected ListView item triggers the following events in this order:
* MouseEnter
* Enter
* MouseDown
* Click
* MouseUp
* ItemClick
* Change
* MouseLeave
* ItemClickEx

With no item currently showing a Delete button; a swipe (left or right) gesture on a non-selected ListView item triggers the following events in this order:
* MouseEnter
* Enter
* MouseDown
* DeleteChangeVisible
* ItemClick
* ItemClickEx


* Click
* MouseUp
* MouseLeave
* Gesture

With one item currently showing a Delete button; a tap on a non-selected ListView item triggers the following events in this order:
* MouseEnter
* Enter
* MouseDown
* DeleteChangeVisible


* Click
* MouseUp
* MouseLeave

Other state combinations may produce different results, but I think the key here for your case is that if OnDeleteChangeVisible occurs, it occurs before a Click or ItemClick event. I imagine a parameter of OnDeleteChangeVisible indicates whether or not the button is visible since that event triggers both when the button is becoming visible and when it's becoming invisible.

So, for lack of knowing a better solution, I think setting a flag in an OnDeleteChangeVisible event handler if the Delete button just became visible is a good idea, then perform your desired action, if any, then in the OnItemClick event handler, perform your "click" action only if the flag is clear, and make sure to always clear the flag before exiting the OnItemClick handler so that a true click later is properly handled.
Head over and check out the full question and answer on Google Plus here.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyIOSLinuxOSXWindows

Bring OpenAI Agents, Vision, Audio, And Realtime AI To Firemonkey

DelphiIDEWindows

Add AI Pair Programming, Refactoring, And Multi-LLM Workflows To RAD Studio

DelphiDemoFiremonkeyLibraryWindows

Bring OpenAI, Local LLMs, And AI Assistants To FMX Apps

DelphiFiremonkeyLibrary

DelphiGemini Brings Native Google Gemini AI Integration To Delphi

Sign up for our Newsletter and
stay informed
[mailpoet_form id="1"]

Leave a Reply