How best to handle long touches in Godot?

Godot Version

4.4.1

Question

I’m managing touches using a custom TouchManager script so that I can support multitouch in my game. I’m using InputEventScreenTouch and InputEventScreenDrag to detect the player’s input.

I want to detect an interaction when the player drags their finger to the edge of the screen and leaves it there

Right now I have something like

if event is InputEventScreenDrag 
    if event.postion.x > hotspot_boundary
      do_the_thing()

It’s doing the thing as you’d expect but only while the player’s touch is moving. I want to continue calling the function while their finger is stationary in the hotspot, until the touch is released.

What would be the best way to approach this in Godot? Am I missing a feature of InputEvents, or would I be better off setting a boolean here and calling my function on _process until the touch is released?

Setting a boolean and calling the function is the way to go.

Thanks for the reply, I spent some time trying to implement a solution like that but ran into a lot of edge cases.

I’ve solved my specific problem by using get_overlapping_bodies() on an Area2D set to the screen edge instead of relying on screen co-ordinates. In case that helps any future readers!