From 5bccc4abf33c4c621d2e9cac9e0d8753a9da1ac9 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:02:27 +0200 Subject: [PATCH] Fix longpress triggering when an onClick discards its actor (#10052) --- core/src/com/unciv/ui/components/input/ActivationListener.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/com/unciv/ui/components/input/ActivationListener.kt b/core/src/com/unciv/ui/components/input/ActivationListener.kt index 16cf63b12d..2f82e99eca 100644 --- a/core/src/com/unciv/ui/components/input/ActivationListener.kt +++ b/core/src/com/unciv/ui/components/input/ActivationListener.kt @@ -17,6 +17,8 @@ class ActivationListener : ActorGestureListener(20f, 0.25f, 1.1f, Int.MAX_VALUE. override fun longPress(actor: Actor?, x: Float, y: Float): Boolean { if (actor == null) return false + // See #10050 - when a tap discards its actor or ascendants, Gdx can't cancel the longpress timer + if (actor.stage == null) return false return actor.activate(ActivationTypes.Longpress) } }