iOS Question How to detect the touch down moment?

Cadenzo

Active Member
Licensed User
Longtime User
I need to measure the time, when the user touches the display or view (finger down), not when it comes up.

The click_event fires when the finger leaves (up) not when it starts to touch (down).

I also tried SwiftButton, the swift-animation is in the down-moment, but the event fires only, when up.

The Touch-Event of a panel fires not in the down moment, only about 250 ms later.
(how can I make the Page-Event to fire? (Private pg As Page, pg.Initialize("pg"), but Sub pg_Touch never fires.)

Here the things, I tried with the results: pg_Touch never fires, Panel1_Touch fires about 250 ms later, Panel1_Click and SwiftButton1_Click fires when finger up, not down. I need the down-moment, because the user should beat a rhythm on the display (in B4A it works). Any ideas?

B4X:
Sub pg_Touch(Action As Int, X As Float, Y As Float)
    Log(Action)
End Sub

Sub Panel1_Touch(Action As Int, X As Float, Y As Float)
    Log(Action)
End Sub

Sub Panel1_Click
    Log ("Panel1_Click")
End Sub

Sub SwiftButton1_Click
    Log ("SwiftButton1_Click")
End Sub
 

Cadenzo

Active Member
Licensed User
Longtime User
Yes, you are right. The latency was only in the log. It was about a quarter second, so I guessed 250 ms. But it works good now.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
I ended up modifying the swiftbutton library so I had a down event as well as a clicked event. I needed similar functionality, but as a button. not a panel.
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
I ended up modifying the swiftbutton library
My problem is solved as I can use the touch event and the delay was only in the log. But this is also a good idea, should become official, a nice view should also have a down event ;-)
If I remember it right, a previous swift button version fired on down event. But I am not sure yet, which lib and which version I tested in the past.
 
Last edited:
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
The other issue with using a modified library, is I have to remove the "swifthbutton" class from the library each time there is an XUIViews update, because they collide and my app wont compile.
 
Upvote 0
Top