From 04239b577d6ec777ea8fb33b9bda8dd876ad9a83 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sat, 28 Sep 2024 04:08:33 +0900 Subject: [PATCH] Update text_cursor_state.rs --- crates/egui/src/text_selection/text_cursor_state.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/egui/src/text_selection/text_cursor_state.rs b/crates/egui/src/text_selection/text_cursor_state.rs index dc75c7dd864..62661254829 100644 --- a/crates/egui/src/text_selection/text_cursor_state.rs +++ b/crates/egui/src/text_selection/text_cursor_state.rs @@ -124,6 +124,11 @@ impl TextCursorState { true } else if response.sense.drag { if response.hovered() && ui.input(|i| i.pointer.any_pressed()) { + // Preserves the text cursor position when right-clicking. + if ui.input(|i| i.pointer.secondary_down()) { + return true; + } + // The start of a drag (or a click). if ui.input(|i| i.modifiers.shift) { if let Some(mut cursor_range) = self.range(galley) {