From 58a27882b0d6d86168dde9c952d2b9b5025a3c68 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 27 Mar 2024 16:39:06 +0100 Subject: [PATCH] Fix touch-and-hold to open context menu (#4249) This was broken in cases where the ui wasn't waking up, i.e. when nothing else was happening. --- crates/egui/src/input_state.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/egui/src/input_state.rs b/crates/egui/src/input_state.rs index a9c1b314..9c6103e0 100644 --- a/crates/egui/src/input_state.rs +++ b/crates/egui/src/input_state.rs @@ -326,6 +326,10 @@ impl InputState { self.pointer.wants_repaint() || self.unprocessed_scroll_delta.abs().max_elem() > 0.2 || !self.events.is_empty() + + // We need to wake up and check for press-and-hold for the context menu. + // TODO(emilk): wake up after `MAX_CLICK_DURATION` instead of every frame. + || (self.any_touches() && !self.pointer.is_decidedly_dragging()) } /// Count presses of a key. If non-zero, the presses are consumed, so that this will only return non-zero once.