Use A Cross Platform Long Tap Event In Delphi XE7 Firemonkey On Android, IOS, OSX, And Windows

Delphi XE7 Firemonkey Cross Platform Long Touch EventDeveloper SangHyun Oh has a blog post up where he demonstrates how to implement your own long tap event in Delphi XE7 Firemonkey. Basically the solution is to use a timer to count the time between the mouse down event and the mouse up event. If it is longer than 0.8 seconds then it counts as a long tap. The reason why I think this is great is because it works across all platforms that Firemonkey supports which are Windows, IOS, OSX, and Android. Firemonkey does actually have a long tap event but it is more complex to implement as it requires the use of the TGestureManager and the OnGesture event. I’ve used some other cross platform frameworks that don’t differentiate between mouse events and tap events. A long mouse click and a long mouse tap are handled the same with the same event. Using the timer like SangHyun demonstrates allows you to do this. It also allows you to debug, test, and use your long tap events on Windows and OSX normally. You can use this with Appmethod as well.

Head over and download the full demo project of implementing your own long tap event cross platform with Delphi XE7 Firemonkey.

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

One Response to Use A Cross Platform Long Tap Event In Delphi XE7 Firemonkey On Android, IOS, OSX, And Windows

  1. Jens Fudge says:

    I needed this longTouch eventhandler in a project I am currently working on. I found this article very useful, but used it only as an inspiration. Instead of using a TTimer I simply used the TStopWatch record from System.Diagnostics

    OnMouseDown (sender : TObject);
    begin
    fStopWatch.StartNew;
    end;

    OnMouseUp(sender : TObject);
    begin
    fStopWatch.Stop;
    If fStopWatch.elapsedMilliseconds > 800 then
    handleLongTap
    else
    handleShortTap;
    end;

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Build An IOS App Without Firemonkey In Object Pascal With Delphi XE7

Developer Simon,Choi has released an IOS app project in Object Pascal for Delphi XE7 that does not use the Firemonkey...

Close